[jboss-cvs] JBossAS SVN: r75080 - in branches/JBPAPP_4_2_0_GA_CP: ejb3 and 43 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 25 14:30:36 EDT 2008
Author: dbhole
Date: 2008-06-25 14:30:35 -0400 (Wed, 25 Jun 2008)
New Revision: 75080
Added:
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/Injectable.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefHandler.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefInjector.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/descriptor/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/Injectable.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefHandler.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefInjector.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/descriptor/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/deployment/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/deployment/ClientDeployer.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/ejb/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/ejb/Container.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/BeanMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/ClientMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/WebMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/web/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/web/AbstractWebDeployer.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/ClientDeployer.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/ejb/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/ejb/Container.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/BeanMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/ClientMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/WebMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/
branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/AbstractWebDeployer.java
Removed:
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/deployment/ClientDeployer.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/Container.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/BeanMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/ClientMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/WebMetaData.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/web/AbstractWebDeployer.java
Modified:
branches/JBPAPP_4_2_0_GA_CP/build/build.xml
branches/JBPAPP_4_2_0_GA_CP/ejb3/build.xml
branches/JBPAPP_4_2_0_GA_CP/server/build.xml
Log:
Fix JBPAPP-706: 4.2/4.3 switching is made more robust by moving 4.2/4.3
specific code files to a separate location, copied in at build time
Modified: branches/JBPAPP_4_2_0_GA_CP/build/build.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/build/build.xml 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/build/build.xml 2008-06-25 18:30:35 UTC (rev 75080)
@@ -312,10 +312,10 @@
| target.
-->
- <target name="modules-all" depends="conditional.eap.patches,_buildmagic:modules:all">
+ <target name="modules-all" depends="_buildmagic:modules:all">
<antcall target="thirdparty" />
</target>
- <target name="modules-most" depends="conditional.eap.patches,_buildmagic:modules:most">
+ <target name="modules-most" depends="_buildmagic:modules:most">
<antcall target="thirdparty" />
</target>
<target name="modules-main" depends="_buildmagic:modules:main"/>
@@ -1084,293 +1084,6 @@
</target>
- <target name="conditional.eap.patches" depends="patch.for.42,patch.for.43"/>
-
- <target name="patch.for.42" unless="build.soa.bits">
-
- <!-- Fix up the EOL characters for Windows files -->
- <antcall target="fixEOL"/>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
-
- <replacetoken><![CDATA[
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- delegate = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
-]]></replacetoken>
-
- <replacevalue><![CDATA[
- Kernel kernel = KernelLocator.getKernel();
- if (kernel != null)
- {
- KernelRegistry registry = kernel.getRegistry();
- KernelRegistryEntry entry = registry.getEntry(ServiceRefHandler.BEAN_NAME);
- delegate = (ServiceRefHandler)entry.getTarget();
- }
- else
- {
- String propName = ServiceRefHandler.class.getName();
- String defaultImpl = "org.jboss.ws.core.client.ServiceRefHandlerImpl";
- delegate = (ServiceRefHandler)FactoryLoader.loadFactory(propName, defaultImpl);
- }
-]]></replacevalue>
- </replace>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
- <replacetoken><![CDATA[
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
-]]></replacetoken>
-
- <replacevalue><![CDATA[
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-]]></replacevalue>
- </replace>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
- <replacetoken><![CDATA[
-import javax.naming.NamingException;
-
-]]></replacetoken>
-
- <replacevalue><![CDATA[
-import javax.naming.NamingException;
-import javax.xml.soap.FactoryLoader;
-
-]]></replacevalue>
- </replace>
-
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/deployment/ClientDeployer.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/ejb/Container.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/BeanMetaData.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/ClientMetaData.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/WebMetaData.java"/>
- </antcall>
- <antcall target="useWS1PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/web/AbstractWebDeployer.java"/>
- </antcall>
-
- </target>
-
- <target name="patch.for.43" if="build.soa.bits">
-
- <!-- Fix up the EOL characters for Windows files -->
- <antcall target="fixEOL"/>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
-
- <replacetoken><![CDATA[
- Kernel kernel = KernelLocator.getKernel();
- if (kernel != null)
- {
- KernelRegistry registry = kernel.getRegistry();
- KernelRegistryEntry entry = registry.getEntry(ServiceRefHandler.BEAN_NAME);
- delegate = (ServiceRefHandler)entry.getTarget();
- }
- else
- {
- String propName = ServiceRefHandler.class.getName();
- String defaultImpl = "org.jboss.ws.core.client.ServiceRefHandlerImpl";
- delegate = (ServiceRefHandler)FactoryLoader.loadFactory(propName, defaultImpl);
- }
-]]></replacetoken>
-
- <replacevalue><![CDATA[
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- delegate = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
-]]></replacevalue>
- </replace>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
- <replacetoken><![CDATA[
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-]]></replacetoken>
-
- <replacevalue><![CDATA[
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
-]]></replacevalue>
- </replace>
-
- <replace file="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"
- summary="true">
- <replacetoken><![CDATA[
-import javax.naming.NamingException;
-import javax.xml.soap.FactoryLoader;
-
-]]></replacetoken>
-
- <replacevalue><![CDATA[
-import javax.naming.NamingException;
-
-]]></replacevalue>
- </replace>
-
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/deployment/ClientDeployer.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/ejb/Container.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/BeanMetaData.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/ClientMetaData.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/metadata/WebMetaData.java"/>
- </antcall>
- <antcall target="useWS2PackageHeirarchy">
- <param name="file.with.ws.imports" value="../server/src/main/org/jboss/web/AbstractWebDeployer.java"/>
- </antcall>
-
- </target>
-
- <target name="useWS1PackageHeirarchy">
- <replace file="${file.with.ws.imports}" summary="true">
- <replacefilter
- token="import org.jboss.wsf.spi.util.KernelLocator"
- value="import org.jboss.ws.integration.KernelLocator"/>
-
- <replacefilter
- token="import org.jboss.wsf.spi.deployment.UnifiedVirtualFile"
- value="import org.jboss.ws.integration.UnifiedVirtualFile"/>
-
- <replacefilter
- token="import org.jboss.wsf.spi.serviceref.ServiceRefElement"
- value="import org.jboss.ws.integration.ServiceRefElement"/>
-
- <replacefilter
- token="import org.jboss.wsf.spi.serviceref.ServiceRefMetaData"
- value="import org.jboss.ws.integration.ServiceRefMetaData"/>
-
- <replacefilter
- token="import org.jboss.wsf.spi.serviceref.ServiceRefHandler"
- value="import org.jboss.ws.integration.ServiceRefHandler"/>
-
- <replacefilter
- token="import org.jboss.wsf.common.URLLoaderAdapter"
- value="import org.jboss.ws.integration.URLLoaderAdapter"/>
- </replace>
- </target>
-
- <target name="useWS2PackageHeirarchy">
- <replace file="${file.with.ws.imports}" summary="true">
- <replacefilter
- token="import org.jboss.ws.integration.KernelLocator"
- value="import org.jboss.wsf.spi.util.KernelLocator"/>
-
- <replacefilter
- token="import org.jboss.ws.integration.UnifiedVirtualFile"
- value="import org.jboss.wsf.spi.deployment.UnifiedVirtualFile"/>
-
- <replacefilter
- token="import org.jboss.ws.integration.ServiceRefElement"
- value="import org.jboss.wsf.spi.serviceref.ServiceRefElement"/>
-
- <replacefilter
- token="import org.jboss.ws.integration.ServiceRefMetaData"
- value="import org.jboss.wsf.spi.serviceref.ServiceRefMetaData"/>
-
- <replacefilter
- token="import org.jboss.ws.integration.ServiceRefHandler"
- value="import org.jboss.wsf.spi.serviceref.ServiceRefHandler"/>
- <replacefilter
- token="import org.jboss.ws.integration.URLLoaderAdapter"
- value="import org.jboss.wsf.common.URLLoaderAdapter"/>
- </replace>
- </target>
-
<!-- Before executing <replace> task on Windows, convert the target files from -->
<!-- UNIX line termination (LF) to Windows line termination (CRLF) so that -->
<!-- <replace> does not break due to line termination inconsistencies -->
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/build.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/build.xml 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/build.xml 2008-06-25 18:30:35 UTC (rev 75080)
@@ -176,6 +176,7 @@
<!-- Where source files live -->
<property name="source.java" value="${module.source}/main"/>
<property name="source.etc" value="${module.source}/etc"/>
+ <property name="source.version.specific" value="${module.output}/versionspecificcode"/>
<property name="resources" value="${module.source}/resources"/>
<!-- Where build generated files will go -->
@@ -224,9 +225,18 @@
<property name="junit.timeout" value="240000"/> <!-- 4 minutes -->
<property name="junit.batchtest.todir" value="${build.reports}"/>
<property name="junit.jvm.options" value="-Ddummy"/>
+
+ <!-- Set it up so that the correct (4.2/4.3 specific) source is used -->
+ <condition property="version.specific.dir" value="${resources}/43specific" else="${resources}/42specific">
+ <isset property="build.soa.bits"/>
+ </condition>
+
+ <copy todir="${source.version.specific}">
+ <fileset dir="${version.specific.dir}"/>
+ </copy>
+
</target>
-
<!-- ================================================================== -->
<!-- Compile -->
<!-- ================================================================== -->
@@ -270,6 +280,7 @@
deprecation="${javac.deprecation}"
failonerror="${javac.fail.onerror}">
<src path="${source.java}"/>
+ <src path="${source.version.specific}"/>
<classpath refid="javac.classpath"/>
<include name="${javac.includes}"/>
<exclude name="${javac.excludes}"/>
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,1491 +0,0 @@
-/*
- * 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.ejb3.metamodel;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.DDObjectFactory;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EnvEntry;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.NameValuePair;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.RunAs;
-import org.jboss.metamodel.descriptor.SecurityRole;
-import org.jboss.metamodel.descriptor.SecurityRoleRef;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
- * chuncks from unmarshaller and assembles them into an EjbJarDD instance.
- *
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author Anil.Saldhana at jboss.org
- * @version <tt>$Revision$</tt>
- */
-public class EjbJarDDObjectFactory extends DDObjectFactory
-{
-
- private static final Logger log = Logger.getLogger(EjbJarDDObjectFactory.class);
-
- public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException
- {
- ObjectModelFactory factory = null;
- Unmarshaller unmarshaller = null;
- EjbJarDD dd = null;
-
- if (ddResource != null)
- {
- log.debug("found ejb-jar.xml " + ddResource);
-
- factory = new EjbJarDDObjectFactory();
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- unmarshaller = unmarshallerFactory.newUnmarshaller();
- unmarshaller.setEntityResolver(new JBossEntityResolver());
- unmarshaller.setNamespaceAware(true);
- unmarshaller.setSchemaValidation(true);
- unmarshaller.setValidation(true);
-
- dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
- }
-
- return dd;
- }
-
- public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
-
- final EjbJarDD dd;
- if (root == null)
- {
- root = dd = new EjbJarDD();
- }
- else
- {
- dd = (EjbJarDD)root;
- }
-
- if (attrs.getLength() > 0)
- {
- for (int i = 0; i < attrs.getLength(); ++i)
- {
- if (attrs.getLocalName(i).equals("version"))
- {
- dd.setVersion(attrs.getValue(i));
- }
- }
- }
-
- return root;
- }
-
- public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
- {
- return root;
- }
-
- // Methods discovered by introspection
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("enterprise-beans"))
- {
- child = new EnterpriseBeans();
- }
- if (localName.equals("interceptors"))
- {
- child = new Interceptors();
- }
- else if (localName.equals("relationships"))
- {
- child = new Relationships();
- }
- else if (localName.equals("assembly-descriptor"))
- {
- child = new AssemblyDescriptor();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("session"))
- {
- child = new SessionEnterpriseBean();
- }
- else if (localName.equals("entity"))
- {
- child = new EntityEnterpriseBean();
- }
- else if (localName.equals("message-driven"))
- {
- child = new MessageDrivenBean();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- private Object newEjbChild(EnterpriseBean parent, String localName)
- {
- Object child = null;
-
- if ((child = super.newEnvRefGroupChild(localName)) != null)
- return child;
- return child;
- }
-
- private Object newEjbHasInterceptorsChild(EnterpriseBean parent, String localName)
- {
- Object child = null;
-
- if (localName.equals("around-invoke"))
- {
- child = new Method();
- }
- else if (localName.equals("post-construct"))
- {
- child = new Method();
- }
- else if (localName.equals("pre-destroy"))
- {
- child = new Method();
- }
- else if (localName.equals("post-activate"))
- {
- child = new Method();
- }
- else if (localName.equals("pre-passivate"))
- {
- child = new Method();
- }
- return child;
- }
-
- public Object newChild(MessageDrivenBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = newEjbChild(parent, localName);
- if (child != null)
- return child;
-
- child = newEjbHasInterceptorsChild(parent, localName);
- if (child != null)
- return child;
-
- if (localName.equals("message-driven-destination"))
- {
- child = new MessageDrivenDestination();
- }
- else if (localName.equals("activation-config"))
- {
- child = new ActivationConfig();
- }
-
- return child;
- }
-
- public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("activation-config-property"))
- {
- child = new NameValuePair();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(SessionEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = newEjbChild(parent, localName);
- if (child != null)
- return child;
-
- child = newEjbHasInterceptorsChild(parent, localName);
- if (child != null)
- return child;
-
- if (localName.equals("security-role-ref"))
- {
- child = new SecurityRoleRef();
- }
- else if (localName.equals("security-identity"))
- {
- child = new SecurityIdentity();
- }
- else if (localName.equals("remove-method"))
- {
- RemoveMethod method = new RemoveMethod();
- parent.addRemoveMethod(method);
- child = method;
- }
- else if (localName.equals("init-method"))
- {
- InitMethod method = new InitMethod();
- parent.addInitMethod(method);
- child = method;
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EntityEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- child = newEjbChild(parent, localName);
- if (child == null)
- {
- if (localName.equals("security-role-ref"))
- {
- child = new SecurityRoleRef();
- }
- else if (localName.equals("cmp-field"))
- {
- child = new CmpField();
- }
- else if (localName.equals("query"))
- {
- child = new Query();
- }
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(SecurityIdentity parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("run-as"))
- {
- child = new RunAs();
- }
- else if (localName.equals("use-caller-identity"))
- {
- parent.setUseCallerIdentity(true);
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(RemoveMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("bean-method"))
- {
- parent.setBeanMethod(new Method());
- child = parent.getBeanMethod();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(InitMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("bean-method"))
- {
- parent.setBeanMethod(new Method());
- child = parent.getBeanMethod();
- }
-
- return child;
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(RemoveMethod dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("retain-if-exception"))
- {
- dd.setRetainIfException(Boolean.parseBoolean(getValue(localName, value)));
- }
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("ejb-relation"))
- {
- child = new EjbRelation();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("ejb-relationship-role"))
- {
- child = new EjbRelationshipRole();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EjbRelationshipRole parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("cascade-delete"))
- {
- parent.setCascadeDelete(true);
- }
- else if (localName.equals("relationship-role-source"))
- {
- child = new RelationshipRoleSource();
- }
- else if (localName.equals("cmr-field"))
- {
- child = new CmrField();
- }
-
- return child;
- }
-
- public Object newChild(Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("interceptor"))
- {
- return new Interceptor();
- }
-
- return child;
- }
-
- public Object newChild(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if ((child = this.newEnvRefGroupChild(localName)) != null)
- return child;
-
- if (localName.equals("around-invoke"))
- {
- return new Method();
- }
- else if (localName.equals("post-construct"))
- {
- return new Method();
- }
- else if (localName.equals("pre-destroy"))
- {
- return new Method();
- }
- else if (localName.equals("post-activate"))
- {
- return new Method();
- }
- else if (localName.equals("pre-passivate"))
- {
- return new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(AssemblyDescriptor relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("security-role"))
- {
- child = new SecurityRole();
- }
- else if (localName.equals("method-permission"))
- {
- child = new MethodPermission();
- }
- if (localName.equals("container-transaction"))
- {
- child = new ContainerTransaction();
- }
- else if (localName.equals("inject"))
- {
- child = new Inject();
- }
- else if (localName.equals("exclude-list"))
- {
- child = new ExcludeList();
- }
- else if (localName.equals("application-exception"))
- {
- child = new ApplicationException();
- }
- else if (localName.equals("interceptor-binding"))
- {
- child = new InterceptorBinding();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
- else if (localName.equals("unchecked"))
- {
- permission.setUnchecked(true);
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(InitList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- public Object newChild(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method-params"))
- {
- method.setHasParameters();
- }
-
- return child;
- }
-
- public Object newChild(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("interceptor-order"))
- {
- child = new InterceptorOrder();
- }
- else if (localName.equals("exclude-default-interceptors"))
- {
- child = new ExcludeDefaultInterceptors();
- }
- else if (localName.equals("exclude-class-interceptors"))
- {
- child = new ExcludeClassInterceptors();
- }
- else if (localName.equals("method-params"))
- {
- binding.setHasParameters();
- }
-
- return child;
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setActivationConfig(config);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbLocalRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnvEntry(entry);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceEnvRef(envRef);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceRef(envRef);
- }
-
- public void addChild(MessageDrivenBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addServiceRef(envRef);
- }
-
- public void addChild(MessageDrivenBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMessageDestinationRef(ref);
- }
-
- public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addActivationConfigProperty(property);
- }
-
- public void addChild(EjbJarDD parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setEnterpriseBeans(ejbs);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, EnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnterpriseBean(ejb);
- }
-
- public void addChild(SessionEnterpriseBean parent, SecurityRoleRef roleRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addSecurityRoleRef(roleRef);
- }
-
- public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setSecurityIdentity(si);
- }
-
- public void addChild(SecurityIdentity parent, RunAs runAs, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setRunAs(runAs);
- }
-
- public void addChild(SessionEnterpriseBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbLocalRef(ref);
- }
-
- public void addChild(SessionEnterpriseBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRef(ref);
- }
-
- public void addChild(SessionEnterpriseBean parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addPersistenceContextRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addPersistenceUnitRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMessageDestinationRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnvEntry(entry);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceEnvRef(envRef);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceRef(envRef);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addServiceRef(envRef);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(SessionEnterpriseBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- if (localName.equals("around-invoke"))
- {
- parent.setAroundInvoke(method);
- }
- else if (localName.equals("post-construct"))
- {
- parent.setPostConstruct(method);
- }
- else if (localName.equals("pre-destroy"))
- {
- parent.setPreDestroy(method);
- }
- else if (localName.equals("post-activate"))
- {
- parent.setPostActivate(method);
- }
- else if (localName.equals("pre-passivate"))
- {
- parent.setPrePassivate(method);
- }
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EntityEnterpriseBean parent, CmpField field, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addCmpField(field);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EntityEnterpriseBean parent, Query query, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addQuery(query);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbJarDD parent, Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setRelationships(relationships);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Relationships parent, EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRelation(relation);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbRelation parent, EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRelationshipRole(role);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbRelationshipRole parent, RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setRelationshipRoleSource(source);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbRelationshipRole parent, CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setCmrField(field);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbJarDD parent, AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setAssemblyDescriptor(descriptor);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addSecurityRole(role);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethodPermission(permission);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setExcludeList(list);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addApplicationException(exception);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, InitList list, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setInitList(list);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addInject(inject);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addInterceptorBinding(binding);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(ExcludeList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(InitList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MethodPermission parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Inject parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- public void addChild(EjbJarDD parent, Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setInterceptors(interceptors);
- }
-
- public void addChild(Interceptors parent, Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addInterceptor(interceptor);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbLocalRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addPersistenceContextRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addPersistenceUnitRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMessageDestinationRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnvEntry(entry);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceEnvRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Interceptor parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addServiceRef(ref);
- }
-
- public void addChild(Interceptor parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- if (localName.equals("around-invoke"))
- {
- parent.setAroundInvoke(method);
- }
- else if (localName.equals("post-construct"))
- {
- parent.setPostConstruct(method);
- }
- else if (localName.equals("pre-destroy"))
- {
- parent.setPreDestroy(method);
- }
- else if (localName.equals("post-activate"))
- {
- parent.setPostActivate(method);
- }
- else if (localName.equals("pre-passivate"))
- {
- parent.setPrePassivate(method);
- }
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(InterceptorBinding parent, InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setOrderedInterceptorClasses(order);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(InterceptorBinding parent, ExcludeDefaultInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setExcludeDefaultInterceptors(true);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(InterceptorBinding parent, ExcludeClassInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setExcludeClassInterceptors(true);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(ContainerTransaction parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setMessageDrivenDestination(destination);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageDrivenBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- if (localName.equals("around-invoke"))
- {
- parent.setAroundInvoke(method);
- }
- else if (localName.equals("post-construct"))
- {
- parent.setPostConstruct(method);
- }
- else if (localName.equals("pre-destroy"))
- {
- parent.setPreDestroy(method);
- }
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(AssemblyDescriptor parent, ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addContainerTransaction(transaction);
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("display-name"))
- {
- dd.setDisplayName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("activation-config-property-name"))
- {
- property.setName(getValue(localName, value));
- }
- else if (localName.equals("activation-config-property-value"))
- {
- property.setValue(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- private boolean isEjbParentName(EnterpriseBean ejb, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- ejb.setEjbName(getValue(localName, value));
- return true;
- }
- else if (localName.equals("home"))
- {
- ejb.setHome(getValue(localName, value));
- return true;
- }
- else if (localName.equals("remote") || localName.equals("business-remote"))
- {
- ejb.setRemote(getValue(localName, value));
- return true;
- }
- else if (localName.equals("local-home"))
- {
- ejb.setLocalHome(getValue(localName, value));
- return true;
- }
- else if (localName.equals("local") || localName.equals("business-local"))
- {
- ejb.setLocal(getValue(localName, value));
- return true;
- }
- else if (localName.equals("ejb-class"))
- {
- ejb.setEjbClass(getValue(localName, value));
- return true;
- }
-
- return false;
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(MessageDrivenBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (!isEjbParentName(ejb, localName, value))
- {
- if (localName.equals("acknowledge-mode"))
- {
- ejb.setAcknowledgeMode(getValue(localName, value));
- }
- else if (localName.equals("transaction-type"))
- {
- ejb.setTransactionType(getValue(localName, value));
- }
- else if (localName.equals("messaging-type"))
- {
- ejb.setMessagingType(getValue(localName, value));
- }
- else if (localName.equals("message-destination-type"))
- {
- MessageDrivenDestination destination = ejb.getMessageDrivenDestination();
- if (destination == null)
- {
- destination = new MessageDrivenDestination();
- ejb.setMessageDrivenDestination(destination);
- }
-
- destination.setDestinationType(getValue(localName, value));
- }
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("destination-type"))
- {
- destination.setDestinationType(getValue(localName, value));
- }
- else if (localName.equals("subscription-durability"))
- {
- destination.setSubscriptionDurability(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(SessionEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (!isEjbParentName(ejb, localName, value))
- {
- if (localName.equals("session-type"))
- {
- ejb.setSessionType(getValue(localName, value));
- }
- else if (localName.equals("transaction-type"))
- {
- ejb.setTransactionManagementType(getValue(localName, value));
- }
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("exception-class"))
- {
- exception.setExceptionClass(getValue(localName, value));
- }
- else if (localName.equals("rollback"))
- {
- exception.setRollback(Boolean.valueOf(getValue(localName, value)));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(EntityEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (!isEjbParentName(ejb, localName, value))
- {
- if (localName.equals("persistence-type"))
- {
- ejb.setPersistenceType(getValue(localName, value));
- }
- }
- }
-
- /**
- * <!ELEMENT security-role-ref (rolename,role-link))>
- */
- public void setValue(SecurityRoleRef parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("role-name"))
- {
- parent.setRoleName(value);
- }
- else if (localName.equals("role-link"))
- {
- parent.setRoleLink(value);
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("use-caller-identity"))
- {
- si.setUseCallerIdentity(true);
- }
- }
-
- public void setValue(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("interceptor-class"))
- {
- interceptor.setInterceptorClass(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-relation-name"))
- {
- relation.setEjbRelationName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-relationship-role-name"))
- {
- role.setEjbRelationshipRoleName(getValue(localName, value));
- }
- else if (localName.equals("multiplicity"))
- {
- role.setMultiplicity(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- source.setEjbName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("cmr-field-name"))
- {
- field.setCmrFieldName(getValue(localName, value));
- }
- else if (localName.equals("cmr-field-type"))
- {
- field.setCmrFieldType(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("role-name"))
- {
- role.setRoleName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("role-name"))
- {
- permission.addRoleName(getValue(localName, value));
- }
- else if (localName.equals("unchecked"))
- {
- permission.setUnchecked(true);
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("trans-attribute"))
- {
- transaction.setTransAttribute(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- method.setEjbName(getValue(localName, value));
- }
- else if (localName.equals("method-name"))
- {
- method.setMethodName(getValue(localName, value));
- }
- else if (localName.equals("method-param"))
- {
- method.addMethodParam(getValue(localName, value));
- }
- else if (localName.equals("lifecycle-callback-method"))
- {
- method.setMethodName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("jndi-name"))
- {
- inject.setJndiName(getValue(localName, value));
- }
- }
-
- public void setValue(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- binding.setEjbName(getValue(localName, value));
- }
- else if (localName.equals("interceptor-class"))
- {
- binding.addInterceptorClass(getValue(localName, value));
- }
- else if (localName.equals("method-name"))
- {
- binding.setMethodName(getValue(localName, value));
- }
- else if (localName.equals("method-param"))
- {
- binding.addMethodParam(getValue(localName, value));
- }
- else if (localName.equals("exclude-default-interceptors"))
- {
- binding.setExcludeDefaultInterceptors(true);
- }
- else if (localName.equals("exclude-class-interceptors"))
- {
- binding.setExcludeClassInterceptors(true);
- }
- }
-
- public void setValue(InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("interceptor-class"))
- {
- order.addInterceptorClass(getValue(localName, value));
- }
- }
-
- // may want to run StringPropertyReplacer on the whole descriptor at once
- protected String getValue(String name, String value)
- {
- if (value.contains("${"))
- {
- String replacement = StringPropertyReplacer.replaceProperties(value);
- if (replacement != null)
- value = replacement;
- }
- return value;
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,352 +0,0 @@
-/*
- * 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.ejb3.metamodel;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.InjectionTarget;
-import org.jboss.metamodel.descriptor.JndiRef;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-
-/**
- * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
- * schema
- *
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * ejbs.setCurrentEjbName(value); } else if
- * (localName.equals("jndi-name")){ ejbs.setJndiName(value);
- * @version <tt>$Revision$</tt>
- */
-public class EnterpriseBeans
-{
- private static final Logger log = Logger.getLogger(EnterpriseBeans.class);
-
- private HashMap<String, EnterpriseBean> enterpriseBeans = new HashMap();
-
- private EnterpriseBean currentEjb;
-
- public void setPoolConfig(PoolConfig config)
- {
- currentEjb.setPoolConfig(config);
- }
-
- public void setDefaultActivationConfig(ActivationConfig config)
- {
- ((MessageDrivenBean)currentEjb).setDefaultActivationConfig(config);
- }
-
- public void setCacheConfig(CacheConfig config)
- {
- ((SessionEnterpriseBean)currentEjb).setCacheConfig(config);
- }
-
- public void setClustered(String clustered)
- {
- ((SessionEnterpriseBean)currentEjb).setClustered(clustered);
- }
-
- public void setConcurrent(String concurrent)
- {
- ((SessionEnterpriseBean)currentEjb).setConcurrent(concurrent);
- }
-
- public void addJndiRef(JndiRef ref)
- {
- currentEjb.addJndiRef(ref);
- }
-
- public void addXmlAnnotation(XmlAnnotation xmlAnnotation)
- {
- currentEjb.addXmlAnnotation(xmlAnnotation);
- }
-
- public void addRemoteBinding(RemoteBinding binding)
- {
- currentEjb.addRemoteBinding(binding);
- }
-
- public void addIgnoreDependency(InjectionTarget ignore)
- {
- currentEjb.addIgnoreDependency(ignore);
- }
-
- public void addResourceRef(ResourceRef ref)
- {
- currentEjb.mergeResourceRef(ref);
- }
-
- public void addResourceEnvRef(ResourceEnvRef ref)
- {
- currentEjb.mergeResourceEnvRef(ref);
- }
-
- public void addMessageDestinationRef(MessageDestinationRef ref)
- {
- currentEjb.mergeMessageDestinationRef(ref);
- }
-
- public void addServiceRef(ServiceRefMetaData ref)
- {
- currentEjb.addServiceRef(ref);
- }
-
- public void setMethodAttributes(MethodAttributes attributes)
- {
- currentEjb.setMethodAttributes(attributes);
- }
-
- public void setCurrentEjbName(String currentEjbName, Class ejbClass)
- {
- currentEjb = createEjbByEjbName(currentEjbName, ejbClass);
- }
-
- public void addDependency(String depends)
- {
- currentEjb.addDependency(depends);
- }
-
- public void updateEjbRef(EjbRef ref)
- {
- currentEjb.updateEjbRef(ref);
- }
-
- public void updateEjbLocalRef(EjbLocalRef ref)
- {
- currentEjb.updateEjbLocalRef(ref);
- }
-
- public void updateResourceRef(ResourceRef ref)
- {
- currentEjb.updateResourceRef(ref);
- }
-
- public void updateResourceEnvRef(ResourceEnvRef ref)
- {
- currentEjb.updateResourceEnvRef(ref);
- }
-
- public void updateMessageDestinationRef(MessageDestinationRef ref)
- {
- currentEjb.updateMessageDestinationRef(ref);
- }
-
- public void setResourceAdapterName(String name)
- {
- ((MessageDrivenBean)currentEjb).setResourceAdaptorName(name);
- }
-
- public void setDestinationJndiName(String name)
- {
- ((MessageDrivenBean)currentEjb).setDestinationJndiName(name);
- }
-
- public void setMdbUser(String name)
- {
- ((MessageDrivenBean)currentEjb).setMdbUser(name);
- }
-
- public void setMdbPassword(String name)
- {
- ((MessageDrivenBean)currentEjb).setMdbPassword(name);
- }
-
- public void setMdbSubscriptionId(String id)
- {
- ((MessageDrivenBean)currentEjb).setMdbSubscriptionId(id);
- }
-
- public void setAopDomainName(String aopDomainName)
- {
- currentEjb.setAopDomainName(aopDomainName);
- }
-
- public void setRunAsPrincipal(String principal)
- {
- currentEjb.setRunAsPrincipal(principal);
- }
-
- public void setClusterConfig(ClusterConfig config)
- {
- ((SessionEnterpriseBean)currentEjb).setClusterConfig(config);
- }
-
- public void setCallByValue(boolean callByValue)
- {
- currentEjb.setCallByValue(callByValue);
- }
-
- public void setJndiName(String jndiName)
- {
- currentEjb.setJndiName(jndiName);
- }
-
- public void setHomeJndiName(String homeJndiName)
- {
- currentEjb.setHomeJndiName(homeJndiName);
- }
-
- public void setSecurityDomain(String securityDomain)
- {
- currentEjb.setSecurityDomain(securityDomain);
- }
-
- public void setLocalJndiName(String jndiName)
- {
- currentEjb.setLocalJndiName(jndiName);
- }
-
- public void setLocalHomeJndiName(String homeJndiName)
- {
- currentEjb.setLocalHomeJndiName(homeJndiName);
- }
-
- public EnterpriseBean createEjbByEjbName(String ejbName, Class ejbClass)
- {
- EnterpriseBean ejb = (EnterpriseBean) enterpriseBeans.get(ejbName);
- if (ejb != null)
- return ejb;
-
- try
- {
- ejb = (EnterpriseBean)ejbClass.newInstance();
- ejb.setEjbName(ejbName);
- enterpriseBeans.put(ejbName, ejb);
- }
- catch (Exception e){}
-
- return ejb;
- }
-
- public EnterpriseBean findEjbByEjbName(String ejbName)
- {
- return enterpriseBeans.get(ejbName);
- }
-
- public List<EnterpriseBean> findEjbsByClass(String className)
- {
- ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>();
-
- Iterator ejbs = enterpriseBeans.values().iterator();
- while (ejbs.hasNext())
- {
- EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
- String ejbClassName = ejb.getEjbClass();
- if (ejbClassName != null && ejbClassName.equals(className))
- result.add(ejb);
- }
- return result;
- }
-
- public List<EnterpriseBean> findEjbs()
- {
- ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>(enterpriseBeans.values().size());
-
- Iterator<EnterpriseBean> ejbs = enterpriseBeans.values().iterator();
- while (ejbs.hasNext())
- {
- result.add(ejbs.next());
- }
- return result;
- }
-
- public EnterpriseBean findEjbByRemote(String remote)
- {
- Iterator ejbs = enterpriseBeans.values().iterator();
- while (ejbs.hasNext())
- {
- EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
- if (ejb.getRemote() != null && ejb.getRemote().equals(remote))
- return ejb;
- }
- return null;
- }
-
- public EnterpriseBean findEjbByLocal(String local)
- {
- Iterator ejbs = enterpriseBeans.values().iterator();
- while (ejbs.hasNext())
- {
- EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
- if (ejb.getLocal() != null && ejb.getLocal().equals(local))
- return ejb;
- }
- return null;
- }
-
- public Collection<EnterpriseBean> getEnterpriseBeans()
- {
- return enterpriseBeans.values();
- }
-
-/* public void setEnterpriseBeans(List enterpriseBeans)
- {
- this.enterpriseBeans = enterpriseBeans;
- }*/
-
- public void addEnterpriseBean(EnterpriseBean ejb)
- {
- enterpriseBeans.put(ejb.getEjbName(), ejb);
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer(100);
- sb.append("[");
- sb.append("enterpriseBeans=").append(enterpriseBeans);
- sb.append("]");
- return sb.toString();
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- return true;
- if (!(o instanceof EnterpriseBeans))
- return false;
-
- final EnterpriseBeans ejbs = (EnterpriseBeans) o;
-
- if (enterpriseBeans != null ? !enterpriseBeans
- .equals(ejbs.enterpriseBeans) : ejbs.enterpriseBeans != null)
- return false;
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = (enterpriseBeans != null ? enterpriseBeans.hashCode() : 0);
- // result = 29 * result + (version != null ? version.hashCode() : 0);
- return result;
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,62 +0,0 @@
-/*
- * 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.ejb3.metamodel;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.JndiRef;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public interface Injectable
-{
-
- Collection<EjbLocalRef> getEjbLocalRefs();
-
- Collection<EjbRef> getEjbRefs();
-
- Collection<ResourceEnvRef> getResourceEnvRefs();
-
- Collection<ResourceRef> getResourceRefs();
-
- Collection<ServiceRefMetaData> getServiceRefs();
-
- Collection<MessageDestinationRef> getMessageDestinationRefs();
-
- List<PersistenceUnitRef> getPersistenceUnitRefs();
-
- List<PersistenceContextRef> getPersistenceContextRefs();
-
- Collection<JndiRef> getJndiRefs();
-}
\ No newline at end of file
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.metamodel;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.DDObjectFactory;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * A JBossXB object factory for parsing JBoss application client descriptor files.
- *
- * http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class JBossClientDDObjectFactory extends DDObjectFactory
-{
- private static final Logger log = Logger.getLogger(JBossClientDDObjectFactory.class);
-
- private ApplicationClientDD dd;
-
- public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException
- {
- // TODO: how to properly fix this
- if (dd == null)
- dd = new ApplicationClientDD();
-
- if (ddResource == null)
- return dd;
-
- log.debug("found jboss-client.xml " + ddResource);
-
- JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd);
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
- unmarshaller.setEntityResolver(new JBossEntityResolver());
- unmarshaller.setNamespaceAware(true);
- unmarshaller.setSchemaValidation(true);
- unmarshaller.setValidation(true);
-
- dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
-
- return dd;
- }
-
- public JBossClientDDObjectFactory(ApplicationClientDD dd)
- {
- // JBossXB will otherwise fail later on
- if (dd == null)
- throw new NullPointerException("dd is null");
-
- this.dd = dd;
- }
-
- public void addChild(ApplicationClientDD parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- dd.updateEjbRef(ref);
- }
-
- public void addChild(ApplicationClientDD parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- dd.updateMessageDestinationRef(ref);
- }
-
- public void addChild(ApplicationClientDD parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- dd.addServiceRef(ref);
- }
-
- public void addChild(ApplicationClientDD dd, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- dd.updateResourceEnvRef(envRef);
- }
-
- public void addChild(ApplicationClientDD parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- dd.updateResourceRef(ref);
- }
-
- public Object completeRoot(Object root, UnmarshallingContext navigator, String uri, String name)
- {
- return root;
- }
-
- public Object newChild(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- child = newEnvRefGroupChild(localName);
- if (child != null)
- return child;
-
- // space for more
-
- return child;
- }
-
- public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- return dd;
- }
-
- public void setValue(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("jndi-name"))
- dd.setJndiName(value);
- else if (localName.equals("depends"))
- dd.addDependency(value);
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,1086 +0,0 @@
-/*
- * 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.ejb3.metamodel;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.DDObjectFactory;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.InjectionTarget;
-import org.jboss.metamodel.descriptor.JndiRef;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.NameValuePair;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.security.SecurityRoleMetaData;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.jboss.util.StringPropertyReplacer;
-import org.xml.sax.Attributes;
-
-/**
- * Represents the jboss.xml deployment descriptor for the 2.1 schema
- *
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author Anil.Saldhana at jboss.com
- * @version <tt>$Revision$</tt>
- */
-public class JBossDDObjectFactory extends DDObjectFactory
-{
- private static final Logger log = Logger.getLogger(JBossDDObjectFactory.class);
-
- private EjbJarDD dd;
- private Class ejbClass;
-
- public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException
- {
- ObjectModelFactory factory = null;
- Unmarshaller unmarshaller = null;
-
- if (ddResource != null)
- {
- log.debug("found jboss.xml " + ddResource);
-
- if (dd == null)
- dd = new EjbJarDD();
-
- factory = new JBossDDObjectFactory(dd);
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- unmarshaller = unmarshallerFactory.newUnmarshaller();
- unmarshaller.setEntityResolver(new JBossEntityResolver());
- unmarshaller.setNamespaceAware(true);
- unmarshaller.setSchemaValidation(true);
- unmarshaller.setValidation(true);
-
- dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
- }
-
- return dd;
- }
-
- public JBossDDObjectFactory(EjbJarDD dd)
- {
- super();
- this.dd = dd;
- }
-
- /**
- * Return the root.
- */
- public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- return dd;
- }
-
- public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
- {
- return root;
- }
-
- // Methods discovered by introspection
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("enterprise-beans"))
- {
- child = dd.getEnterpriseBeans();
- if (child == null)
- {
- dd.setEnterpriseBeans(new EnterpriseBeans());
- child = dd.getEnterpriseBeans();
- }
- }
- else if (localName.equals("assembly-descriptor"))
- {
- child = dd.getAssemblyDescriptor();
- if (child == null)
- {
- dd.setAssemblyDescriptor(new AssemblyDescriptor());
- child = dd.getAssemblyDescriptor();
- }
- }
- else if (localName.equals("resource-manager"))
- {
- child = new ResourceManager();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if ((child = this.newEnvRefGroupChild(localName)) != null)
- return child;
-
- if (localName.equals("current-message"))
- {
- child = new CurrentMessage();
- }
- else if (localName.equals("message-properties"))
- {
- child = new MessageProperties();
- }
- else if (localName.equals("producer"))
- {
- child = new Producer(false);
- }
- else if (localName.equals("local-producer"))
- {
- child = new Producer(true);
- }
- else if (localName.equals("annotation"))
- {
- child = new XmlAnnotation();
- }
- else if (localName.equals("ignore-dependency"))
- {
- child = new InjectionTarget();
- }
- else if (localName.equals("remote-binding"))
- {
- child = new RemoteBinding();
- }
- else if (localName.equals("pool-config"))
- {
- child = new PoolConfig();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if ((child = this.newEnvRefGroupChild(localName)) != null)
- return child;
-
- if (localName.equals("ignore-dependency"))
- {
- child = new InjectionTarget();
- }
- else if (localName.equals("annotation"))
- {
- child = new XmlAnnotation();
- }
- else if (localName.equals("remote-binding"))
- {
- child = new RemoteBinding();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("method"))
- {
- child = new Method();
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("message-destination"))
- {
- child = new MessageDestination();
- }
- if (localName.equals("security-role"))
- {
- child = new SecurityRoleMetaData("dummy_to_be_replaced_in_setValue");
- }
-
- return child;
- }
-
- /**
- * Called when parsing of a new element started.
- */
- public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if ((child = this.newEnvRefGroupChild(localName)) != null)
- {
- return child;
- }
-
- if (localName.equals("session"))
- {
- ejbClass = SessionEnterpriseBean.class;
- child = ejbs;
- }
- else if (localName.equals("message-driven"))
- {
- ejbClass = MessageDrivenBean.class;
- child = ejbs;
- }
- else if (localName.equals("service"))
- {
- child = new Service();
- }
- else if (localName.equals("consumer"))
- {
- child = new Consumer();
- }
- else if (localName.equals("method-attributes"))
- {
- child = new MethodAttributes();
- }
- else if (localName.equals("annotation"))
- {
- child = new XmlAnnotation();
- }
- else if (localName.equals("ignore-dependency"))
- {
- child = new InjectionTarget();
- }
- else if (localName.equals("cluster-config"))
- {
- child = new ClusterConfig();
- }
- else if (localName.equals("remote-binding"))
- {
- child = new RemoteBinding();
- }
- else if (localName.equals("cache-config"))
- {
- child = new CacheConfig();
- }
- else if (localName.equals("pool-config"))
- {
- child = new PoolConfig();
- }
- else if (localName.equals("default-activation-config"))
- {
- child = new ActivationConfig();
- }
-
- return child;
- }
-
- public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("default-activation-config-property"))
- {
- child = new NameValuePair();
- }
-
- return child;
- }
-
- public Object newChild(XmlAnnotation parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("injection-target"))
- {
- child = new InjectionTarget();
- }
- else if (localName.equals("property"))
- {
- child = new NameValuePair();
- }
-
- return child;
- }
-
- public void addChild(XmlAnnotation parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addProperty(property);
- }
-
- public void addChild(XmlAnnotation parent, InjectionTarget injectionTarget, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setInjectionTarget(injectionTarget);
- }
-
- public void addChild(EnterpriseBeans parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setDefaultActivationConfig(config);
- }
-
- public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addActivationConfigProperty(property);
- }
-
- public void addChild(Consumer parent, Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- if (producer.isLocal())
- parent.addLocalProducer(producer);
- else parent.addProducer(producer);
- }
-
- public void addChild(Consumer parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addRemoteBinding(binding);
- }
-
- public void addChild(AssemblyDescriptor parent, MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMessageDestination(destination);
- }
-
- public void addChild(AssemblyDescriptor parent, SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addSecurityRoleMetaData(srm);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setCacheConfig(config);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setPoolConfig(config);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setMethodAttributes(attributes);
- }
-
- public void addChild(EnterpriseBeans parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addRemoteBinding(binding);
- }
-
- public void addChild(EnterpriseBeans parent, InjectionTarget ignoreDependency, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addIgnoreDependency(ignoreDependency);
- }
-
- public void addChild(EnterpriseBeans parent, XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addXmlAnnotation(xmlAnnotation);
- }
-
- public void addChild(MethodAttributes parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- public void addChild(Consumer parent, CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setCurrentMessage(message);
- }
-
- public void addChild(Consumer parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setPoolConfig(config);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, MessageProperties message, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setMessageProperties(message);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(CurrentMessage parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(MessageProperties parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addMethod(method);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, Service service, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnterpriseBean(service);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addRemoteBinding(binding);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbLocalRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addJndiRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Service parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceEnvRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEjbLocalRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addJndiRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(Consumer parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceEnvRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addEnterpriseBean(consumer);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addJndiRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EjbJarDD parent, ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addResourceManager(manager);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.updateEjbRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.updateEjbLocalRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.setClusterConfig(config);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.updateResourceRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.updateMessageDestinationRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.addServiceRef(ref);
- }
-
- /**
- * Called when parsing character is complete.
- */
- public void addChild(EnterpriseBeans parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
- {
- parent.updateResourceEnvRef(ref);
- }
-
- public void setValue(XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("annotation-class"))
- {
- xmlAnnotation.setAnnotationClass(getValue(localName, value));
- }
- else if (localName.equals("annotation-implementation-class"))
- {
- xmlAnnotation.setAnnotationImplementationClass(getValue(localName, value));
- }
- }
-
- public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("activation-config-property-name") || localName.equals("message-driven-config-property-name") || localName.equals("property-name"))
- {
- property.setName(getValue(localName, value));
- }
- else if (localName.equals("activation-config-property-value") || localName.equals("message-driven-config-property-value") || localName.equals("property-value"))
- {
- property.setValue(getValue(localName, value));
- }
- }
-
- public void setValue(ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("res-name"))
- {
- manager.setResourceName(getValue(localName, value));
- }
- else if (localName.equals("res-jndi-name"))
- {
- manager.setResourceJndiName(getValue(localName, value));
- }
- }
-
- public void setValue(MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("message-destination-name"))
- {
- destination.setMessageDestinationName(getValue(localName, value));
- }
- else if (localName.equals("jndi-name"))
- {
- destination.setJndiName(getValue(localName, value));
- }
- }
-
- public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- ejbs.setCurrentEjbName(value, ejbClass);
- }
- else if (localName.equals("jndi-name"))
- {
- ejbs.setJndiName(getValue(localName, value));
- }
- else if (localName.equals("home-jndi-name"))
- {
- ejbs.setHomeJndiName(getValue(localName, value));
- }
- else if (localName.equals("local-jndi-name"))
- {
- ejbs.setLocalJndiName(getValue(localName, value));
- }
- else if (localName.equals("local-home-jndi-name"))
- {
- ejbs.setLocalHomeJndiName(getValue(localName, value));
- }
- else if (localName.equals("security-domain"))
- {
- ejbs.setSecurityDomain(getValue(localName, value));
- }
- else if (localName.equals("depends"))
- {
- ejbs.addDependency(getValue(localName, value));
- }
- else if (localName.equals("run-as-principal"))
- {
- ejbs.setRunAsPrincipal(getValue(localName, value));
- }
- else if (localName.equals("aop-domain-name"))
- {
- ejbs.setAopDomainName(getValue(localName, value));
- }
- else if (localName.equals("resource-adapter-name"))
- {
- ejbs.setResourceAdapterName(getValue(localName, value));
- }
- else if (localName.equals("destination-jndi-name"))
- {
- ejbs.setDestinationJndiName(getValue(localName, value));
- }
- else if (localName.equals("mdb-user"))
- {
- ejbs.setMdbUser(getValue(localName, value));
- }
- else if (localName.equals("mdb-passwd"))
- {
- ejbs.setMdbPassword(getValue(localName, value));
- }
- else if (localName.equals("mdb-subscription-id"))
- {
- ejbs.setMdbSubscriptionId(getValue(localName, value));
- }
- else if (localName.equals("clustered"))
- {
- ejbs.setClustered(getValue(localName, value));
- }
- else if (localName.equals("concurrent"))
- {
- ejbs.setConcurrent(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("ejb-name"))
- {
- service.setEjbName(getValue(localName, value));
- }
- if (localName.equals("object-name"))
- {
- service.setObjectName(getValue(localName, value));
- }
- else if (localName.equals("ejb-class"))
- {
- service.setEjbClass(getValue(localName, value));
- }
- if (localName.equals("xmbean"))
- {
- service.setXMBean(getValue(localName, value));
- }
- else if (localName.equals("local"))
- {
- service.setLocal(getValue(localName, value));
- }
- else if (localName.equals("remote"))
- {
- service.setRemote(getValue(localName, value));
- }
- else if (localName.equals("management"))
- {
- service.setManagement(getValue(localName, value));
- }
- else if (localName.equals("jndi-name"))
- {
- service.setJndiName(getValue(localName, value));
- }
- else if (localName.equals("local-jndi-name"))
- {
- service.setLocalJndiName(getValue(localName, value));
- }
- else if (localName.equals("security-domain"))
- {
- service.setSecurityDomain(getValue(localName, value));
- }
- else if (localName.equals("aop-domain-name"))
- {
- service.setAopDomainName(getValue(localName, value));
- }
- else if (localName.equals("depends"))
- {
- service.addDependency(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("message-destination"))
- {
- consumer.setDestination(getValue(localName, value));
- }
- else if (localName.equals("message-destination-type"))
- {
- consumer.setDestinationType(getValue(localName, value));
- }
- else if (localName.equals("ejb-class"))
- {
- consumer.setEjbClass(getValue(localName, value));
- consumer.setEjbName(getValue(localName, value));
- }
- else if (localName.equals("local"))
- {
- consumer.setLocal(getValue(localName, value));
- }
- else if (localName.equals("remote"))
- {
- consumer.setRemote(getValue(localName, value));
- }
- else if (localName.equals("jndi-name"))
- {
- consumer.setJndiName(getValue(localName, value));
- }
- else if (localName.equals("local-jndi-name"))
- {
- consumer.setLocalJndiName(getValue(localName, value));
- }
- else if (localName.equals("security-domain"))
- {
- consumer.setSecurityDomain(getValue(localName, value));
- }
- else if (localName.equals("run-as-principal"))
- {
- consumer.setRunAsPrincipal(getValue(localName, value));
- }
- else if (localName.equals("aop-domain-name"))
- {
- consumer.setAopDomainName(getValue(localName, value));
- }
- else if (localName.equals("depends"))
- {
- consumer.addDependency(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("jndi-name"))
- {
- binding.setJndiName(getValue(localName, value));
- }
- else if (localName.equals("client-bind-url"))
- {
- binding.setClientBindUrl(getValue(localName, value));
- }
- else if (localName.equals("proxy-factory"))
- {
- binding.setProxyFactory(getValue(localName, value));
- }
- else if (localName.equals("interceptor-stack"))
- {
- binding.setInterceptorStack(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("delivery"))
- {
- properties.setDelivery(getValue(localName, value));
- }
- else if (localName.equals("class"))
- {
- properties.setClassName(getValue(localName, value));
- }
- else if (localName.equals("priority"))
- {
- properties.setPriority(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("load-balance-policy"))
- {
- config.setLoadBalancePolicy(getValue(localName, value));
- }
- else if (localName.equals("partition-name"))
- {
- config.setPartition(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("cache-class"))
- {
- config.setCacheClass(getValue(localName, value));
- }
- else if (localName.equals("cache-max-size"))
- {
- config.setMaxSize(getValue(localName, value));
- }
- else if (localName.equals("idle-timeout-seconds"))
- {
- config.setIdleTimeoutSeconds(getValue(localName, value));
- }
- else if (localName.equals("remove-timeout-seconds"))
- {
- config.setRemoveTimeoutSeconds(getValue(localName, value));
- }
- else if (localName.equals("cache-name"))
- {
- config.setName(getValue(localName, value));
- }
- else if (localName.equals("persistence-manager"))
- {
- config.setPersistenceManager(getValue(localName, value));
- }
- else if (localName.equals("replication-is-passivation"))
- {
- config.setReplicationIsPassivation(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("pool-class"))
- {
- config.setPoolClass(getValue(localName, value));
- }
- else if (localName.equals("pool-max-size"))
- {
- config.setMaxSize(getValue(localName, value));
- }
- else if (localName.equals("pool-timeout"))
- {
- config.setTimeout(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("method-name"))
- {
- method.setMethodName(getValue(localName, value));
- }
- else if (localName.equals("transaction-timeout"))
- {
- method.setTransactionTimeout(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("security-domain"))
- {
- dd.setSecurityDomain(getValue(localName, value));
- }
- else if (localName.equals("unauthenticated-principal"))
- {
- dd.setUnauthenticatedPrincipal(getValue(localName, value));
- }
- else if (localName.equals("jmx-name"))
- {
- dd.setJmxName(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("class"))
- {
- producer.setClassName(getValue(localName, value));
- }
- else if (localName.equals("connection-factory"))
- {
- producer.setConnectionFactory(getValue(localName, value));
- }
- }
-
- /**
- * Called when a child element with simple content is read for DD.
- */
- public void setValue(SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (localName.equals("role-name"))
- {
-// FIXME: NYI
-// srm.setRoleName(getValue(localName, value));
- throw new RuntimeException("NYI");
- }
- else if (localName.equals("principal-name"))
- {
- srm.addPrincipalName(getValue(localName, value));
- }
- }
-
- // may want to run StringPropertyReplacer on the whole descriptor at once
- protected String getValue(String name, String value)
- {
- if (value.contains("${"))
- {
- String replacement = StringPropertyReplacer.replaceProperties(value);
- if (replacement != null)
- value = replacement;
- }
- return value;
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,151 +0,0 @@
-/*
- * 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.injection;
-
-// $Id$
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.Context;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-
-/**
- * Handle @WebServiceRef annotations
- *
- * @author Thomas.Diesler at jboss.com
- */
-public class WebServiceRefHandler implements InjectionHandler
-{
- private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
- private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
-
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
- {
- if (xml == null) return;
- if (xml.getServiceRefs() == null) return;
- for (ServiceRefMetaData sref : xml.getServiceRefs())
- {
- log.debug("@WebServiceRef override: " + sref);
- if (srefMap.get(sref.getServiceRefName()) != null)
- throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
-
- srefMap.put(sref.getServiceRefName(), sref);
- }
- }
-
- public void handleClassAnnotations(Class type, InjectionContainer container)
- {
- WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
- if (wsref != null)
- {
- bindRefOnType(type, container, wsref);
- }
-
- WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
- if (refs != null)
- {
- for (WebServiceRef refItem : refs.value())
- {
- bindRefOnType(type, container, refItem);
- }
- }
- }
-
- private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
- {
- String name = wsref.name();
- if (name.equals(""))
- name = InjectionUtil.getEncName(type).substring(4);
-
- if (!container.getEncInjectors().containsKey(name))
- {
- String encName = "env/" + name;
- ServiceRefMetaData sref = getServiceRefForName(name);
- container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
- }
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
- if (wsref == null) return;
-
- if (!method.getName().startsWith("set"))
- throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
-
- String name = wsref.name();
- if (name.equals(""))
- name = InjectionUtil.getEncName(method).substring(4);
-
- String encName = "env/" + name;
- Context encCtx = container.getEnc();
- if (!container.getEncInjectors().containsKey(name))
- {
- ServiceRefMetaData sref = getServiceRefForName(name);
- container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
- }
-
- injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
- if (wsref == null) return;
-
- String name = wsref.name();
- if (name.equals(""))
- name = InjectionUtil.getEncName(field).substring(4);
-
- String encName = "env/" + name;
- Context encCtx = container.getEnc();
- if (!container.getEncInjectors().containsKey(name))
- {
- ServiceRefMetaData sref = getServiceRefForName(name);
- container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
- }
-
- injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
- }
-
- private ServiceRefMetaData getServiceRefForName(String name)
- {
- ServiceRefMetaData sref = srefMap.get(name);
- if (sref == null)
- {
- log.debug("No override for @WebServiceRef.name: " + name);
- sref = new ServiceRefDelegate().newServiceRefMetaData();
- sref.setServiceRefName(name);
- }
- return sref;
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,84 +0,0 @@
-/*
- * 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.injection;
-
-// $Id$
-
-import java.lang.reflect.AnnotatedElement;
-import java.net.URL;
-
-import javax.naming.Context;
-import javax.xml.ws.WebServiceException;
-
-import org.jboss.ejb3.DeploymentUnit;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.wsf.common.URLLoaderAdapter;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-
-/**
- * Inject a jaxws web service ref.
- *
- * @author Thomas.Diesler at jboss.com
- * @version $Revision$
- */
-public class WebServiceRefInjector implements EncInjector
-{
- private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
-
- private String name;
- private ServiceRefMetaData sref;
-
- public WebServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
- {
- this.name = name;
- this.sref = sref;
- this.sref.setAnnotatedElement(anElement);
- }
-
- public void inject(InjectionContainer container)
- {
- try
- {
- Context encCtx = container.getEnc();
- EJBContainer ejbContainer = (EJBContainer)container;
- DeploymentUnit unit = ejbContainer.getDeploymentUnit();
- URL rootURL = unit.getUrl();
-
- ClassLoader loader = unit.getClassLoader();
- URLLoaderAdapter vfsRoot = new URLLoaderAdapter(rootURL);
- new ServiceRefDelegate().bindServiceRef(encCtx, name, vfsRoot, loader, sref);
-
- log.debug("@WebServiceRef bound [env=" + name + "]");
- }
- catch (Exception e)
- {
- throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + "]", e);
- }
- }
-
- public String toString()
- {
- return super.toString() + "{enc=" + name + "}";
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,241 +0,0 @@
-/*
- * 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.metamodel.descriptor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @version <tt>$Revision$</tt>
- */
-public abstract class EnvironmentRefGroup
-{
- private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class);
-
- protected HashMap<String, EjbLocalRef> ejbLocalRefs = new HashMap<String, EjbLocalRef>();
- protected HashMap<String, EjbRef> ejbRefs = new HashMap<String, EjbRef>();
- protected HashMap<String, EnvEntry> envEntries = new HashMap<String, EnvEntry>();
- protected HashMap<String, ResourceEnvRef> resourceEnvRefs = new HashMap<String, ResourceEnvRef>();
- protected HashMap<String, ResourceRef> resourceRefs = new HashMap<String, ResourceRef>();
- protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
- /** An index of MessageDestinationRef keyed by message-destination-link values */
- protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
- protected HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
- protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
- protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
- protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
-
- public Collection<MessageDestinationRef> getMessageDestinationRefs()
- {
- return messageDestinationRefs.values();
- }
-
- public void addMessageDestinationRef(MessageDestinationRef ref)
- {
- log.debug("addMessageDestinationRef, "+ref);
- messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref);
- String link = ref.getMessageDestinationLink();
- if( link != null )
- {
- messageDestinationRefsByLink.put(link, ref);
- }
- }
-
- public Collection<EjbLocalRef> getEjbLocalRefs()
- {
- return ejbLocalRefs.values();
- }
-
- public void addEjbLocalRef(EjbLocalRef ref)
- {
- ejbLocalRefs.put(ref.getEjbRefName(), ref);
- }
-
- public Collection<EjbRef> getEjbRefs()
- {
- return ejbRefs.values();
- }
-
- public void addEjbRef(EjbRef ref)
- {
- ejbRefs.put(ref.getEjbRefName(), ref);
- }
-
- public Collection<EnvEntry> getEnvEntries()
- {
- return envEntries.values();
- }
-
- public void addEnvEntry(EnvEntry entry)
- {
- envEntries.put(entry.getEnvEntryName(), entry);
- }
-
- public Collection<ResourceEnvRef> getResourceEnvRefs()
- {
- return resourceEnvRefs.values();
- }
-
- public void addResourceEnvRef(ResourceEnvRef envRef)
- {
- resourceEnvRefs.put(envRef.getResRefName(), envRef);
- }
-
- public Collection<ResourceRef> getResourceRefs()
- {
- return resourceRefs.values();
- }
-
- public void addResourceRef(ResourceRef ref)
- {
- resourceRefs.put(ref.getResRefName(), ref);
- }
-
- public Collection<JndiRef> getJndiRefs()
- {
- return jndiRefs.values();
- }
-
- public void addJndiRef(JndiRef ref)
- {
- jndiRefs.put(ref.getJndiRefName(), ref);
- }
-
- public Collection<ServiceRefMetaData> getServiceRefs()
- {
- return serviceRefs.values();
- }
-
- public void addServiceRef(ServiceRefMetaData ref)
- {
- serviceRefs.put(ref.getServiceRefName(), ref);
- }
-
- public void updateEjbRef(EjbRef updatedRef)
- {
- EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName());
- if (ref != null)
- {
- ref.setMappedName(updatedRef.getMappedName());
- ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
- }
- else
- {
- ejbRefs.put(updatedRef.getEjbRefName(), updatedRef);
- }
- }
-
- public void updateEjbLocalRef(EjbLocalRef updatedRef)
- {
- EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName());
- if (ref != null)
- {
- ref.setMappedName(updatedRef.getMappedName());
- ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
- }
- else
- {
- ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef);
- }
- }
-
- public void updateResourceRef(ResourceRef updatedRef)
- {
- ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName());
- if (ref != null)
- {
- ref.setMappedName(updatedRef.getMappedName());
- ref.setResUrl(updatedRef.getResUrl());
- ref.setResourceName(updatedRef.getResourceName());
- }
- else
- {
- resourceRefs.put(updatedRef.getResRefName(), updatedRef);
- }
- }
-
- public void updateResourceEnvRef(ResourceEnvRef updatedRef)
- {
- ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName());
- if (ref != null)
- {
- ref.setMappedName(updatedRef.getMappedName());
- }
- else
- {
- resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef);
- }
- }
-
- public void updateMessageDestinationRef(MessageDestinationRef updatedRef)
- {
- log.debug("updateMessageDestinationRef, "+updatedRef);
- MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName());
- if (ref != null)
- {
- ref.setMappedName(updatedRef.getMappedName());
- }
- else
- {
- messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef);
- ref = updatedRef;
- }
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer(100);
- return sb.toString();
- }
-
- public List<PersistenceContextRef> getPersistenceContextRefs()
- {
- return persistenceContextRefs;
- }
-
- public List<PersistenceUnitRef> getPersistenceUnitRefs()
- {
- return persistenceUnitRefs;
- }
-
- public void addPersistenceContextRef(PersistenceContextRef ref)
- {
- persistenceContextRefs.add(ref);
- }
-
- public void addPersistenceUnitRef(PersistenceUnitRef ref)
- {
- persistenceUnitRefs.add(ref);
- }
-
- public MessageDestinationRef getMessageDestinationRefForLink(String link)
- {
- MessageDestinationRef ref = messageDestinationRefsByLink.get(link);
- return ref;
- }
-}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1491 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.EnvEntry;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.metamodel.descriptor.RunAs;
+import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
+ * chuncks from unmarshaller and assembles them into an EjbJarDD instance.
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.org
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EjbJarDDObjectFactory extends DDObjectFactory
+{
+
+ private static final Logger log = Logger.getLogger(EjbJarDDObjectFactory.class);
+
+ public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+ EjbJarDD dd = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found ejb-jar.xml " + ddResource);
+
+ factory = new EjbJarDDObjectFactory();
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+
+ final EjbJarDD dd;
+ if (root == null)
+ {
+ root = dd = new EjbJarDD();
+ }
+ else
+ {
+ dd = (EjbJarDD)root;
+ }
+
+ if (attrs.getLength() > 0)
+ {
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ if (attrs.getLocalName(i).equals("version"))
+ {
+ dd.setVersion(attrs.getValue(i));
+ }
+ }
+ }
+
+ return root;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = new EnterpriseBeans();
+ }
+ if (localName.equals("interceptors"))
+ {
+ child = new Interceptors();
+ }
+ else if (localName.equals("relationships"))
+ {
+ child = new Relationships();
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = new AssemblyDescriptor();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("session"))
+ {
+ child = new SessionEnterpriseBean();
+ }
+ else if (localName.equals("entity"))
+ {
+ child = new EntityEnterpriseBean();
+ }
+ else if (localName.equals("message-driven"))
+ {
+ child = new MessageDrivenBean();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ private Object newEjbChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if ((child = super.newEnvRefGroupChild(localName)) != null)
+ return child;
+ return child;
+ }
+
+ private Object newEjbHasInterceptorsChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if (localName.equals("around-invoke"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ child = new Method();
+ }
+ return child;
+ }
+
+ public Object newChild(MessageDrivenBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("message-driven-destination"))
+ {
+ child = new MessageDrivenDestination();
+ }
+ else if (localName.equals("activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SessionEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("security-identity"))
+ {
+ child = new SecurityIdentity();
+ }
+ else if (localName.equals("remove-method"))
+ {
+ RemoveMethod method = new RemoveMethod();
+ parent.addRemoveMethod(method);
+ child = method;
+ }
+ else if (localName.equals("init-method"))
+ {
+ InitMethod method = new InitMethod();
+ parent.addInitMethod(method);
+ child = method;
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EntityEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEjbChild(parent, localName);
+ if (child == null)
+ {
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("cmp-field"))
+ {
+ child = new CmpField();
+ }
+ else if (localName.equals("query"))
+ {
+ child = new Query();
+ }
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SecurityIdentity parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("run-as"))
+ {
+ child = new RunAs();
+ }
+ else if (localName.equals("use-caller-identity"))
+ {
+ parent.setUseCallerIdentity(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(RemoveMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoveMethod dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("retain-if-exception"))
+ {
+ dd.setRetainIfException(Boolean.parseBoolean(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relation"))
+ {
+ child = new EjbRelation();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relationship-role"))
+ {
+ child = new EjbRelationshipRole();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelationshipRole parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("cascade-delete"))
+ {
+ parent.setCascadeDelete(true);
+ }
+ else if (localName.equals("relationship-role-source"))
+ {
+ child = new RelationshipRoleSource();
+ }
+ else if (localName.equals("cmr-field"))
+ {
+ child = new CmrField();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor"))
+ {
+ return new Interceptor();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("around-invoke"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ return new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRole();
+ }
+ else if (localName.equals("method-permission"))
+ {
+ child = new MethodPermission();
+ }
+ if (localName.equals("container-transaction"))
+ {
+ child = new ContainerTransaction();
+ }
+ else if (localName.equals("inject"))
+ {
+ child = new Inject();
+ }
+ else if (localName.equals("exclude-list"))
+ {
+ child = new ExcludeList();
+ }
+ else if (localName.equals("application-exception"))
+ {
+ child = new ApplicationException();
+ }
+ else if (localName.equals("interceptor-binding"))
+ {
+ child = new InterceptorBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method-params"))
+ {
+ method.setHasParameters();
+ }
+
+ return child;
+ }
+
+ public Object newChild(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor-order"))
+ {
+ child = new InterceptorOrder();
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ child = new ExcludeDefaultInterceptors();
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ child = new ExcludeClassInterceptors();
+ }
+ else if (localName.equals("method-params"))
+ {
+ binding.setHasParameters();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setActivationConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(EjbJarDD parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setEnterpriseBeans(ejbs);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(ejb);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityRoleRef roleRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleRef(roleRef);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setSecurityIdentity(si);
+ }
+
+ public void addChild(SecurityIdentity parent, RunAs runAs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRunAs(runAs);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, CmpField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addCmpField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, Query query, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addQuery(query);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationships(relationships);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Relationships parent, EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelation(relation);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelation parent, EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelationshipRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationshipRoleSource(source);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCmrField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setAssemblyDescriptor(descriptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethodPermission(permission);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addApplicationException(exception);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InitList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInitList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInject(inject);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptorBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ExcludeList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InitList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MethodPermission parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Inject parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(EjbJarDD parent, Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInterceptors(interceptors);
+ }
+
+ public void addChild(Interceptors parent, Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptor(interceptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ public void addChild(Interceptor parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setOrderedInterceptorClasses(order);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeDefaultInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeDefaultInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeClassInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeClassInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ContainerTransaction parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageDrivenDestination(destination);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addContainerTransaction(transaction);
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("display-name"))
+ {
+ dd.setDisplayName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ private boolean isEjbParentName(EnterpriseBean ejb, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejb.setEjbName(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("home"))
+ {
+ ejb.setHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("remote") || localName.equals("business-remote"))
+ {
+ ejb.setRemote(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local-home"))
+ {
+ ejb.setLocalHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local") || localName.equals("business-local"))
+ {
+ ejb.setLocal(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ ejb.setEjbClass(getValue(localName, value));
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("acknowledge-mode"))
+ {
+ ejb.setAcknowledgeMode(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionType(getValue(localName, value));
+ }
+ else if (localName.equals("messaging-type"))
+ {
+ ejb.setMessagingType(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ MessageDrivenDestination destination = ejb.getMessageDrivenDestination();
+ if (destination == null)
+ {
+ destination = new MessageDrivenDestination();
+ ejb.setMessageDrivenDestination(destination);
+ }
+
+ destination.setDestinationType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("destination-type"))
+ {
+ destination.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("subscription-durability"))
+ {
+ destination.setSubscriptionDurability(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SessionEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("session-type"))
+ {
+ ejb.setSessionType(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionManagementType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("exception-class"))
+ {
+ exception.setExceptionClass(getValue(localName, value));
+ }
+ else if (localName.equals("rollback"))
+ {
+ exception.setRollback(Boolean.valueOf(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EntityEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("persistence-type"))
+ {
+ ejb.setPersistenceType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * <!ELEMENT security-role-ref (rolename,role-link))>
+ */
+ public void setValue(SecurityRoleRef parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ parent.setRoleName(value);
+ }
+ else if (localName.equals("role-link"))
+ {
+ parent.setRoleLink(value);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("use-caller-identity"))
+ {
+ si.setUseCallerIdentity(true);
+ }
+ }
+
+ public void setValue(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ interceptor.setInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relation-name"))
+ {
+ relation.setEjbRelationName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relationship-role-name"))
+ {
+ role.setEjbRelationshipRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("multiplicity"))
+ {
+ role.setMultiplicity(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ source.setEjbName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cmr-field-name"))
+ {
+ field.setCmrFieldName(getValue(localName, value));
+ }
+ else if (localName.equals("cmr-field-type"))
+ {
+ field.setCmrFieldType(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ role.setRoleName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ permission.addRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("trans-attribute"))
+ {
+ transaction.setTransAttribute(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ method.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ method.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("lifecycle-callback-method"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ inject.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ binding.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-class"))
+ {
+ binding.addInterceptorClass(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ binding.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ binding.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ binding.setExcludeDefaultInterceptors(true);
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ binding.setExcludeClassInterceptors(true);
+ }
+ }
+
+ public void setValue(InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ order.addInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,352 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.ws.integration.ServiceRefMetaData;
+
+/**
+ * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
+ * schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * ejbs.setCurrentEjbName(value); } else if
+ * (localName.equals("jndi-name")){ ejbs.setJndiName(value);
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EnterpriseBeans
+{
+ private static final Logger log = Logger.getLogger(EnterpriseBeans.class);
+
+ private HashMap<String, EnterpriseBean> enterpriseBeans = new HashMap();
+
+ private EnterpriseBean currentEjb;
+
+ public void setPoolConfig(PoolConfig config)
+ {
+ currentEjb.setPoolConfig(config);
+ }
+
+ public void setDefaultActivationConfig(ActivationConfig config)
+ {
+ ((MessageDrivenBean)currentEjb).setDefaultActivationConfig(config);
+ }
+
+ public void setCacheConfig(CacheConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setCacheConfig(config);
+ }
+
+ public void setClustered(String clustered)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClustered(clustered);
+ }
+
+ public void setConcurrent(String concurrent)
+ {
+ ((SessionEnterpriseBean)currentEjb).setConcurrent(concurrent);
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ currentEjb.addJndiRef(ref);
+ }
+
+ public void addXmlAnnotation(XmlAnnotation xmlAnnotation)
+ {
+ currentEjb.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addRemoteBinding(RemoteBinding binding)
+ {
+ currentEjb.addRemoteBinding(binding);
+ }
+
+ public void addIgnoreDependency(InjectionTarget ignore)
+ {
+ currentEjb.addIgnoreDependency(ignore);
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ currentEjb.mergeResourceRef(ref);
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.mergeResourceEnvRef(ref);
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.mergeMessageDestinationRef(ref);
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ currentEjb.addServiceRef(ref);
+ }
+
+ public void setMethodAttributes(MethodAttributes attributes)
+ {
+ currentEjb.setMethodAttributes(attributes);
+ }
+
+ public void setCurrentEjbName(String currentEjbName, Class ejbClass)
+ {
+ currentEjb = createEjbByEjbName(currentEjbName, ejbClass);
+ }
+
+ public void addDependency(String depends)
+ {
+ currentEjb.addDependency(depends);
+ }
+
+ public void updateEjbRef(EjbRef ref)
+ {
+ currentEjb.updateEjbRef(ref);
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef ref)
+ {
+ currentEjb.updateEjbLocalRef(ref);
+ }
+
+ public void updateResourceRef(ResourceRef ref)
+ {
+ currentEjb.updateResourceRef(ref);
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.updateResourceEnvRef(ref);
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.updateMessageDestinationRef(ref);
+ }
+
+ public void setResourceAdapterName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setResourceAdaptorName(name);
+ }
+
+ public void setDestinationJndiName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setDestinationJndiName(name);
+ }
+
+ public void setMdbUser(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbUser(name);
+ }
+
+ public void setMdbPassword(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbPassword(name);
+ }
+
+ public void setMdbSubscriptionId(String id)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbSubscriptionId(id);
+ }
+
+ public void setAopDomainName(String aopDomainName)
+ {
+ currentEjb.setAopDomainName(aopDomainName);
+ }
+
+ public void setRunAsPrincipal(String principal)
+ {
+ currentEjb.setRunAsPrincipal(principal);
+ }
+
+ public void setClusterConfig(ClusterConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClusterConfig(config);
+ }
+
+ public void setCallByValue(boolean callByValue)
+ {
+ currentEjb.setCallByValue(callByValue);
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ currentEjb.setJndiName(jndiName);
+ }
+
+ public void setHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setHomeJndiName(homeJndiName);
+ }
+
+ public void setSecurityDomain(String securityDomain)
+ {
+ currentEjb.setSecurityDomain(securityDomain);
+ }
+
+ public void setLocalJndiName(String jndiName)
+ {
+ currentEjb.setLocalJndiName(jndiName);
+ }
+
+ public void setLocalHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setLocalHomeJndiName(homeJndiName);
+ }
+
+ public EnterpriseBean createEjbByEjbName(String ejbName, Class ejbClass)
+ {
+ EnterpriseBean ejb = (EnterpriseBean) enterpriseBeans.get(ejbName);
+ if (ejb != null)
+ return ejb;
+
+ try
+ {
+ ejb = (EnterpriseBean)ejbClass.newInstance();
+ ejb.setEjbName(ejbName);
+ enterpriseBeans.put(ejbName, ejb);
+ }
+ catch (Exception e){}
+
+ return ejb;
+ }
+
+ public EnterpriseBean findEjbByEjbName(String ejbName)
+ {
+ return enterpriseBeans.get(ejbName);
+ }
+
+ public List<EnterpriseBean> findEjbsByClass(String className)
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>();
+
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ String ejbClassName = ejb.getEjbClass();
+ if (ejbClassName != null && ejbClassName.equals(className))
+ result.add(ejb);
+ }
+ return result;
+ }
+
+ public List<EnterpriseBean> findEjbs()
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>(enterpriseBeans.values().size());
+
+ Iterator<EnterpriseBean> ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ result.add(ejbs.next());
+ }
+ return result;
+ }
+
+ public EnterpriseBean findEjbByRemote(String remote)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getRemote() != null && ejb.getRemote().equals(remote))
+ return ejb;
+ }
+ return null;
+ }
+
+ public EnterpriseBean findEjbByLocal(String local)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getLocal() != null && ejb.getLocal().equals(local))
+ return ejb;
+ }
+ return null;
+ }
+
+ public Collection<EnterpriseBean> getEnterpriseBeans()
+ {
+ return enterpriseBeans.values();
+ }
+
+/* public void setEnterpriseBeans(List enterpriseBeans)
+ {
+ this.enterpriseBeans = enterpriseBeans;
+ }*/
+
+ public void addEnterpriseBean(EnterpriseBean ejb)
+ {
+ enterpriseBeans.put(ejb.getEjbName(), ejb);
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append("[");
+ sb.append("enterpriseBeans=").append(enterpriseBeans);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ return true;
+ if (!(o instanceof EnterpriseBeans))
+ return false;
+
+ final EnterpriseBeans ejbs = (EnterpriseBeans) o;
+
+ if (enterpriseBeans != null ? !enterpriseBeans
+ .equals(ejbs.enterpriseBeans) : ejbs.enterpriseBeans != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (enterpriseBeans != null ? enterpriseBeans.hashCode() : 0);
+ // result = 29 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/Injectable.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/Injectable.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/Injectable.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,62 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.ws.integration.ServiceRefMetaData;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 69712 $
+ */
+public interface Injectable
+{
+
+ Collection<EjbLocalRef> getEjbLocalRefs();
+
+ Collection<EjbRef> getEjbRefs();
+
+ Collection<ResourceEnvRef> getResourceEnvRefs();
+
+ Collection<ResourceRef> getResourceRefs();
+
+ Collection<ServiceRefMetaData> getServiceRefs();
+
+ Collection<MessageDestinationRef> getMessageDestinationRefs();
+
+ List<PersistenceUnitRef> getPersistenceUnitRefs();
+
+ List<PersistenceContextRef> getPersistenceContextRefs();
+
+ Collection<JndiRef> getJndiRefs();
+}
\ No newline at end of file
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * A JBossXB object factory for parsing JBoss application client descriptor files.
+ *
+ * http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossClientDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossClientDDObjectFactory.class);
+
+ private ApplicationClientDD dd;
+
+ public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException
+ {
+ // TODO: how to properly fix this
+ if (dd == null)
+ dd = new ApplicationClientDD();
+
+ if (ddResource == null)
+ return dd;
+
+ log.debug("found jboss-client.xml " + ddResource);
+
+ JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+
+ return dd;
+ }
+
+ public JBossClientDDObjectFactory(ApplicationClientDD dd)
+ {
+ // JBossXB will otherwise fail later on
+ if (dd == null)
+ throw new NullPointerException("dd is null");
+
+ this.dd = dd;
+ }
+
+ public void addChild(ApplicationClientDD parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateEjbRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateMessageDestinationRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.addServiceRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD dd, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceEnvRef(envRef);
+ }
+
+ public void addChild(ApplicationClientDD parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceRef(ref);
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext navigator, String uri, String name)
+ {
+ return root;
+ }
+
+ public Object newChild(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEnvRefGroupChild(localName);
+ if (child != null)
+ return child;
+
+ // space for more
+
+ return child;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public void setValue(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ dd.setJndiName(value);
+ else if (localName.equals("depends"))
+ dd.addDependency(value);
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1086 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.security.SecurityRoleMetaData;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.util.StringPropertyReplacer;
+import org.xml.sax.Attributes;
+
+/**
+ * Represents the jboss.xml deployment descriptor for the 2.1 schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.com
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class JBossDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossDDObjectFactory.class);
+
+ private EjbJarDD dd;
+ private Class ejbClass;
+
+ public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found jboss.xml " + ddResource);
+
+ if (dd == null)
+ dd = new EjbJarDD();
+
+ factory = new JBossDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public JBossDDObjectFactory(EjbJarDD dd)
+ {
+ super();
+ this.dd = dd;
+ }
+
+ /**
+ * Return the root.
+ */
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = dd.getEnterpriseBeans();
+ if (child == null)
+ {
+ dd.setEnterpriseBeans(new EnterpriseBeans());
+ child = dd.getEnterpriseBeans();
+ }
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = dd.getAssemblyDescriptor();
+ if (child == null)
+ {
+ dd.setAssemblyDescriptor(new AssemblyDescriptor());
+ child = dd.getAssemblyDescriptor();
+ }
+ }
+ else if (localName.equals("resource-manager"))
+ {
+ child = new ResourceManager();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("current-message"))
+ {
+ child = new CurrentMessage();
+ }
+ else if (localName.equals("message-properties"))
+ {
+ child = new MessageProperties();
+ }
+ else if (localName.equals("producer"))
+ {
+ child = new Producer(false);
+ }
+ else if (localName.equals("local-producer"))
+ {
+ child = new Producer(true);
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("message-destination"))
+ {
+ child = new MessageDestination();
+ }
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRoleMetaData("dummy_to_be_replaced_in_setValue");
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ {
+ return child;
+ }
+
+ if (localName.equals("session"))
+ {
+ ejbClass = SessionEnterpriseBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("message-driven"))
+ {
+ ejbClass = MessageDrivenBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("service"))
+ {
+ child = new Service();
+ }
+ else if (localName.equals("consumer"))
+ {
+ child = new Consumer();
+ }
+ else if (localName.equals("method-attributes"))
+ {
+ child = new MethodAttributes();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("cluster-config"))
+ {
+ child = new ClusterConfig();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("cache-config"))
+ {
+ child = new CacheConfig();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+ else if (localName.equals("default-activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("default-activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public Object newChild(XmlAnnotation parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("injection-target"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public void addChild(XmlAnnotation parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addProperty(property);
+ }
+
+ public void addChild(XmlAnnotation parent, InjectionTarget injectionTarget, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInjectionTarget(injectionTarget);
+ }
+
+ public void addChild(EnterpriseBeans parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setDefaultActivationConfig(config);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(Consumer parent, Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (producer.isLocal())
+ parent.addLocalProducer(producer);
+ else parent.addProducer(producer);
+ }
+
+ public void addChild(Consumer parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(AssemblyDescriptor parent, MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestination(destination);
+ }
+
+ public void addChild(AssemblyDescriptor parent, SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleMetaData(srm);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCacheConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethodAttributes(attributes);
+ }
+
+ public void addChild(EnterpriseBeans parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(EnterpriseBeans parent, InjectionTarget ignoreDependency, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addIgnoreDependency(ignoreDependency);
+ }
+
+ public void addChild(EnterpriseBeans parent, XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addChild(MethodAttributes parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(Consumer parent, CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCurrentMessage(message);
+ }
+
+ public void addChild(Consumer parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, MessageProperties message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageProperties(message);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(CurrentMessage parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageProperties parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Service service, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(service);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(consumer);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceManager(manager);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setClusterConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceEnvRef(ref);
+ }
+
+ public void setValue(XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("annotation-class"))
+ {
+ xmlAnnotation.setAnnotationClass(getValue(localName, value));
+ }
+ else if (localName.equals("annotation-implementation-class"))
+ {
+ xmlAnnotation.setAnnotationImplementationClass(getValue(localName, value));
+ }
+ }
+
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name") || localName.equals("message-driven-config-property-name") || localName.equals("property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value") || localName.equals("message-driven-config-property-value") || localName.equals("property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ public void setValue(ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("res-name"))
+ {
+ manager.setResourceName(getValue(localName, value));
+ }
+ else if (localName.equals("res-jndi-name"))
+ {
+ manager.setResourceJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination-name"))
+ {
+ destination.setMessageDestinationName(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ destination.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejbs.setCurrentEjbName(value, ejbClass);
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ ejbs.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("home-jndi-name"))
+ {
+ ejbs.setHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ ejbs.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-home-jndi-name"))
+ {
+ ejbs.setLocalHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ ejbs.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ ejbs.addDependency(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ ejbs.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ ejbs.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("resource-adapter-name"))
+ {
+ ejbs.setResourceAdapterName(getValue(localName, value));
+ }
+ else if (localName.equals("destination-jndi-name"))
+ {
+ ejbs.setDestinationJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-user"))
+ {
+ ejbs.setMdbUser(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-passwd"))
+ {
+ ejbs.setMdbPassword(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-subscription-id"))
+ {
+ ejbs.setMdbSubscriptionId(getValue(localName, value));
+ }
+ else if (localName.equals("clustered"))
+ {
+ ejbs.setClustered(getValue(localName, value));
+ }
+ else if (localName.equals("concurrent"))
+ {
+ ejbs.setConcurrent(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ service.setEjbName(getValue(localName, value));
+ }
+ if (localName.equals("object-name"))
+ {
+ service.setObjectName(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ service.setEjbClass(getValue(localName, value));
+ }
+ if (localName.equals("xmbean"))
+ {
+ service.setXMBean(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ service.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ service.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("management"))
+ {
+ service.setManagement(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ service.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ service.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ service.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ service.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ service.addDependency(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination"))
+ {
+ consumer.setDestination(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ consumer.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ consumer.setEjbClass(getValue(localName, value));
+ consumer.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ consumer.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ consumer.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ consumer.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ consumer.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ consumer.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ consumer.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ consumer.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ consumer.addDependency(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ binding.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("client-bind-url"))
+ {
+ binding.setClientBindUrl(getValue(localName, value));
+ }
+ else if (localName.equals("proxy-factory"))
+ {
+ binding.setProxyFactory(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-stack"))
+ {
+ binding.setInterceptorStack(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("delivery"))
+ {
+ properties.setDelivery(getValue(localName, value));
+ }
+ else if (localName.equals("class"))
+ {
+ properties.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("priority"))
+ {
+ properties.setPriority(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("load-balance-policy"))
+ {
+ config.setLoadBalancePolicy(getValue(localName, value));
+ }
+ else if (localName.equals("partition-name"))
+ {
+ config.setPartition(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cache-class"))
+ {
+ config.setCacheClass(getValue(localName, value));
+ }
+ else if (localName.equals("cache-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("idle-timeout-seconds"))
+ {
+ config.setIdleTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("remove-timeout-seconds"))
+ {
+ config.setRemoveTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("cache-name"))
+ {
+ config.setName(getValue(localName, value));
+ }
+ else if (localName.equals("persistence-manager"))
+ {
+ config.setPersistenceManager(getValue(localName, value));
+ }
+ else if (localName.equals("replication-is-passivation"))
+ {
+ config.setReplicationIsPassivation(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("pool-class"))
+ {
+ config.setPoolClass(getValue(localName, value));
+ }
+ else if (localName.equals("pool-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("pool-timeout"))
+ {
+ config.setTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-timeout"))
+ {
+ method.setTransactionTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("security-domain"))
+ {
+ dd.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("unauthenticated-principal"))
+ {
+ dd.setUnauthenticatedPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("jmx-name"))
+ {
+ dd.setJmxName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("class"))
+ {
+ producer.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("connection-factory"))
+ {
+ producer.setConnectionFactory(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+// FIXME: NYI
+// srm.setRoleName(getValue(localName, value));
+ throw new RuntimeException("NYI");
+ }
+ else if (localName.equals("principal-name"))
+ {
+ srm.addPrincipalName(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefHandler.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefHandler.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,151 @@
+/*
+ * 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.injection;
+
+// $Id: WebServiceRefHandler.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.ws.integration.ServiceRefMetaData;
+
+/**
+ * Handle @WebServiceRef annotations
+ *
+ * @author Thomas.Diesler at jboss.com
+ */
+public class WebServiceRefHandler implements InjectionHandler
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
+ private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
+
+ public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ {
+ if (xml == null) return;
+ if (xml.getServiceRefs() == null) return;
+ for (ServiceRefMetaData sref : xml.getServiceRefs())
+ {
+ log.debug("@WebServiceRef override: " + sref);
+ if (srefMap.get(sref.getServiceRefName()) != null)
+ throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
+
+ srefMap.put(sref.getServiceRefName(), sref);
+ }
+ }
+
+ public void handleClassAnnotations(Class type, InjectionContainer container)
+ {
+ WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
+ if (wsref != null)
+ {
+ bindRefOnType(type, container, wsref);
+ }
+
+ WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
+ if (refs != null)
+ {
+ for (WebServiceRef refItem : refs.value())
+ {
+ bindRefOnType(type, container, refItem);
+ }
+ }
+ }
+
+ private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
+ {
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(type).substring(4);
+
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ String encName = "env/" + name;
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
+ }
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ if (!method.getName().startsWith("set"))
+ throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(method).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
+ }
+
+ injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(field).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
+ }
+
+ injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
+ }
+
+ private ServiceRefMetaData getServiceRefForName(String name)
+ {
+ ServiceRefMetaData sref = srefMap.get(name);
+ if (sref == null)
+ {
+ log.debug("No override for @WebServiceRef.name: " + name);
+ sref = new ServiceRefDelegate().newServiceRefMetaData();
+ sref.setServiceRefName(name);
+ }
+ return sref;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefInjector.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/injection/WebServiceRefInjector.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,84 @@
+/*
+ * 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.injection;
+
+// $Id: WebServiceRefInjector.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.ws.integration.URLLoaderAdapter;
+import org.jboss.ws.integration.ServiceRefMetaData;
+
+/**
+ * Inject a jaxws web service ref.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision: 69712 $
+ */
+public class WebServiceRefInjector implements EncInjector
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
+
+ private String name;
+ private ServiceRefMetaData sref;
+
+ public WebServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
+ {
+ this.name = name;
+ this.sref = sref;
+ this.sref.setAnnotatedElement(anElement);
+ }
+
+ public void inject(InjectionContainer container)
+ {
+ try
+ {
+ Context encCtx = container.getEnc();
+ EJBContainer ejbContainer = (EJBContainer)container;
+ DeploymentUnit unit = ejbContainer.getDeploymentUnit();
+ URL rootURL = unit.getUrl();
+
+ ClassLoader loader = unit.getClassLoader();
+ URLLoaderAdapter vfsRoot = new URLLoaderAdapter(rootURL);
+ new ServiceRefDelegate().bindServiceRef(encCtx, name, vfsRoot, loader, sref);
+
+ log.debug("@WebServiceRef bound [env=" + name + "]");
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + "]", e);
+ }
+ }
+
+ public String toString()
+ {
+ return super.toString() + "{enc=" + name + "}";
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/42specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,241 @@
+/*
+ * 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.metamodel.descriptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.integration.ServiceRefMetaData;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public abstract class EnvironmentRefGroup
+{
+ private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class);
+
+ protected HashMap<String, EjbLocalRef> ejbLocalRefs = new HashMap<String, EjbLocalRef>();
+ protected HashMap<String, EjbRef> ejbRefs = new HashMap<String, EjbRef>();
+ protected HashMap<String, EnvEntry> envEntries = new HashMap<String, EnvEntry>();
+ protected HashMap<String, ResourceEnvRef> resourceEnvRefs = new HashMap<String, ResourceEnvRef>();
+ protected HashMap<String, ResourceRef> resourceRefs = new HashMap<String, ResourceRef>();
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
+ /** An index of MessageDestinationRef keyed by message-destination-link values */
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
+ protected HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
+ protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
+ protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
+ protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
+
+ public Collection<MessageDestinationRef> getMessageDestinationRefs()
+ {
+ return messageDestinationRefs.values();
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ log.debug("addMessageDestinationRef, "+ref);
+ messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref);
+ String link = ref.getMessageDestinationLink();
+ if( link != null )
+ {
+ messageDestinationRefsByLink.put(link, ref);
+ }
+ }
+
+ public Collection<EjbLocalRef> getEjbLocalRefs()
+ {
+ return ejbLocalRefs.values();
+ }
+
+ public void addEjbLocalRef(EjbLocalRef ref)
+ {
+ ejbLocalRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EjbRef> getEjbRefs()
+ {
+ return ejbRefs.values();
+ }
+
+ public void addEjbRef(EjbRef ref)
+ {
+ ejbRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EnvEntry> getEnvEntries()
+ {
+ return envEntries.values();
+ }
+
+ public void addEnvEntry(EnvEntry entry)
+ {
+ envEntries.put(entry.getEnvEntryName(), entry);
+ }
+
+ public Collection<ResourceEnvRef> getResourceEnvRefs()
+ {
+ return resourceEnvRefs.values();
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef envRef)
+ {
+ resourceEnvRefs.put(envRef.getResRefName(), envRef);
+ }
+
+ public Collection<ResourceRef> getResourceRefs()
+ {
+ return resourceRefs.values();
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ resourceRefs.put(ref.getResRefName(), ref);
+ }
+
+ public Collection<JndiRef> getJndiRefs()
+ {
+ return jndiRefs.values();
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ jndiRefs.put(ref.getJndiRefName(), ref);
+ }
+
+ public Collection<ServiceRefMetaData> getServiceRefs()
+ {
+ return serviceRefs.values();
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ serviceRefs.put(ref.getServiceRefName(), ref);
+ }
+
+ public void updateEjbRef(EjbRef updatedRef)
+ {
+ EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef updatedRef)
+ {
+ EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceRef(ResourceRef updatedRef)
+ {
+ ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setResUrl(updatedRef.getResUrl());
+ ref.setResourceName(updatedRef.getResourceName());
+ }
+ else
+ {
+ resourceRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef updatedRef)
+ {
+ ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef updatedRef)
+ {
+ log.debug("updateMessageDestinationRef, "+updatedRef);
+ MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef);
+ ref = updatedRef;
+ }
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ return sb.toString();
+ }
+
+ public List<PersistenceContextRef> getPersistenceContextRefs()
+ {
+ return persistenceContextRefs;
+ }
+
+ public List<PersistenceUnitRef> getPersistenceUnitRefs()
+ {
+ return persistenceUnitRefs;
+ }
+
+ public void addPersistenceContextRef(PersistenceContextRef ref)
+ {
+ persistenceContextRefs.add(ref);
+ }
+
+ public void addPersistenceUnitRef(PersistenceUnitRef ref)
+ {
+ persistenceUnitRefs.add(ref);
+ }
+
+ public MessageDestinationRef getMessageDestinationRefForLink(String link)
+ {
+ MessageDestinationRef ref = messageDestinationRefsByLink.get(link);
+ return ref;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1491 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.EnvEntry;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.metamodel.descriptor.RunAs;
+import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.metamodel.descriptor.SecurityRoleRef;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
+ * chuncks from unmarshaller and assembles them into an EjbJarDD instance.
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.org
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EjbJarDDObjectFactory extends DDObjectFactory
+{
+
+ private static final Logger log = Logger.getLogger(EjbJarDDObjectFactory.class);
+
+ public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+ EjbJarDD dd = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found ejb-jar.xml " + ddResource);
+
+ factory = new EjbJarDDObjectFactory();
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+
+ final EjbJarDD dd;
+ if (root == null)
+ {
+ root = dd = new EjbJarDD();
+ }
+ else
+ {
+ dd = (EjbJarDD)root;
+ }
+
+ if (attrs.getLength() > 0)
+ {
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ if (attrs.getLocalName(i).equals("version"))
+ {
+ dd.setVersion(attrs.getValue(i));
+ }
+ }
+ }
+
+ return root;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = new EnterpriseBeans();
+ }
+ if (localName.equals("interceptors"))
+ {
+ child = new Interceptors();
+ }
+ else if (localName.equals("relationships"))
+ {
+ child = new Relationships();
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = new AssemblyDescriptor();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("session"))
+ {
+ child = new SessionEnterpriseBean();
+ }
+ else if (localName.equals("entity"))
+ {
+ child = new EntityEnterpriseBean();
+ }
+ else if (localName.equals("message-driven"))
+ {
+ child = new MessageDrivenBean();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ private Object newEjbChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if ((child = super.newEnvRefGroupChild(localName)) != null)
+ return child;
+ return child;
+ }
+
+ private Object newEjbHasInterceptorsChild(EnterpriseBean parent, String localName)
+ {
+ Object child = null;
+
+ if (localName.equals("around-invoke"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ child = new Method();
+ }
+ return child;
+ }
+
+ public Object newChild(MessageDrivenBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("message-driven-destination"))
+ {
+ child = new MessageDrivenDestination();
+ }
+ else if (localName.equals("activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SessionEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = newEjbChild(parent, localName);
+ if (child != null)
+ return child;
+
+ child = newEjbHasInterceptorsChild(parent, localName);
+ if (child != null)
+ return child;
+
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("security-identity"))
+ {
+ child = new SecurityIdentity();
+ }
+ else if (localName.equals("remove-method"))
+ {
+ RemoveMethod method = new RemoveMethod();
+ parent.addRemoveMethod(method);
+ child = method;
+ }
+ else if (localName.equals("init-method"))
+ {
+ InitMethod method = new InitMethod();
+ parent.addInitMethod(method);
+ child = method;
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EntityEnterpriseBean parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEjbChild(parent, localName);
+ if (child == null)
+ {
+ if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRef();
+ }
+ else if (localName.equals("cmp-field"))
+ {
+ child = new CmpField();
+ }
+ else if (localName.equals("query"))
+ {
+ child = new Query();
+ }
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(SecurityIdentity parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("run-as"))
+ {
+ child = new RunAs();
+ }
+ else if (localName.equals("use-caller-identity"))
+ {
+ parent.setUseCallerIdentity(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(RemoveMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitMethod parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("bean-method"))
+ {
+ parent.setBeanMethod(new Method());
+ child = parent.getBeanMethod();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoveMethod dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("retain-if-exception"))
+ {
+ dd.setRetainIfException(Boolean.parseBoolean(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relation"))
+ {
+ child = new EjbRelation();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("ejb-relationship-role"))
+ {
+ child = new EjbRelationshipRole();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbRelationshipRole parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("cascade-delete"))
+ {
+ parent.setCascadeDelete(true);
+ }
+ else if (localName.equals("relationship-role-source"))
+ {
+ child = new RelationshipRoleSource();
+ }
+ else if (localName.equals("cmr-field"))
+ {
+ child = new CmrField();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor"))
+ {
+ return new Interceptor();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("around-invoke"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-construct"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("post-activate"))
+ {
+ return new Method();
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ return new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor relationships, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRole();
+ }
+ else if (localName.equals("method-permission"))
+ {
+ child = new MethodPermission();
+ }
+ if (localName.equals("container-transaction"))
+ {
+ child = new ContainerTransaction();
+ }
+ else if (localName.equals("inject"))
+ {
+ child = new Inject();
+ }
+ else if (localName.equals("exclude-list"))
+ {
+ child = new ExcludeList();
+ }
+ else if (localName.equals("application-exception"))
+ {
+ child = new ApplicationException();
+ }
+ else if (localName.equals("interceptor-binding"))
+ {
+ child = new InterceptorBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(InitList list, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ public Object newChild(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method-params"))
+ {
+ method.setHasParameters();
+ }
+
+ return child;
+ }
+
+ public Object newChild(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("interceptor-order"))
+ {
+ child = new InterceptorOrder();
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ child = new ExcludeDefaultInterceptors();
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ child = new ExcludeClassInterceptors();
+ }
+ else if (localName.equals("method-params"))
+ {
+ binding.setHasParameters();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setActivationConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ public void addChild(MessageDrivenBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(EjbJarDD parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setEnterpriseBeans(ejbs);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(ejb);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityRoleRef roleRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleRef(roleRef);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setSecurityIdentity(si);
+ }
+
+ public void addChild(SecurityIdentity parent, RunAs runAs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRunAs(runAs);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ public void addChild(SessionEnterpriseBean parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ResourceRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(envRef);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(SessionEnterpriseBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, CmpField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addCmpField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EntityEnterpriseBean parent, Query query, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addQuery(query);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, Relationships relationships, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationships(relationships);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Relationships parent, EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelation(relation);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelation parent, EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRelationshipRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setRelationshipRoleSource(source);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbRelationshipRole parent, CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCmrField(field);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setAssemblyDescriptor(descriptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRole(role);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethodPermission(permission);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ExcludeList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addApplicationException(exception);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InitList list, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInitList(list);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInject(inject);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptorBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ExcludeList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InitList parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MethodPermission parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Inject parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(EjbJarDD parent, Interceptors interceptors, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInterceptors(interceptors);
+ }
+
+ public void addChild(Interceptors parent, Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addInterceptor(interceptor);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceContextRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addPersistenceUnitRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, EnvEntry entry, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnvEntry(entry);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Interceptor parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ public void addChild(Interceptor parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ else if (localName.equals("post-activate"))
+ {
+ parent.setPostActivate(method);
+ }
+ else if (localName.equals("pre-passivate"))
+ {
+ parent.setPrePassivate(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setOrderedInterceptorClasses(order);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeDefaultInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeDefaultInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(InterceptorBinding parent, ExcludeClassInterceptors exclude, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setExcludeClassInterceptors(true);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(ContainerTransaction parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageDrivenDestination(destination);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageDrivenBean parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (localName.equals("around-invoke"))
+ {
+ parent.setAroundInvoke(method);
+ }
+ else if (localName.equals("post-construct"))
+ {
+ parent.setPostConstruct(method);
+ }
+ else if (localName.equals("pre-destroy"))
+ {
+ parent.setPreDestroy(method);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(AssemblyDescriptor parent, ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addContainerTransaction(transaction);
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("display-name"))
+ {
+ dd.setDisplayName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ private boolean isEjbParentName(EnterpriseBean ejb, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejb.setEjbName(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("home"))
+ {
+ ejb.setHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("remote") || localName.equals("business-remote"))
+ {
+ ejb.setRemote(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local-home"))
+ {
+ ejb.setLocalHome(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("local") || localName.equals("business-local"))
+ {
+ ejb.setLocal(getValue(localName, value));
+ return true;
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ ejb.setEjbClass(getValue(localName, value));
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("acknowledge-mode"))
+ {
+ ejb.setAcknowledgeMode(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionType(getValue(localName, value));
+ }
+ else if (localName.equals("messaging-type"))
+ {
+ ejb.setMessagingType(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ MessageDrivenDestination destination = ejb.getMessageDrivenDestination();
+ if (destination == null)
+ {
+ destination = new MessageDrivenDestination();
+ ejb.setMessageDrivenDestination(destination);
+ }
+
+ destination.setDestinationType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageDrivenDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("destination-type"))
+ {
+ destination.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("subscription-durability"))
+ {
+ destination.setSubscriptionDurability(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SessionEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("session-type"))
+ {
+ ejb.setSessionType(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-type"))
+ {
+ ejb.setTransactionManagementType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ApplicationException exception, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("exception-class"))
+ {
+ exception.setExceptionClass(getValue(localName, value));
+ }
+ else if (localName.equals("rollback"))
+ {
+ exception.setRollback(Boolean.valueOf(getValue(localName, value)));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EntityEnterpriseBean ejb, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (!isEjbParentName(ejb, localName, value))
+ {
+ if (localName.equals("persistence-type"))
+ {
+ ejb.setPersistenceType(getValue(localName, value));
+ }
+ }
+ }
+
+ /**
+ * <!ELEMENT security-role-ref (rolename,role-link))>
+ */
+ public void setValue(SecurityRoleRef parent, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ parent.setRoleName(value);
+ }
+ else if (localName.equals("role-link"))
+ {
+ parent.setRoleLink(value);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityIdentity si, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("use-caller-identity"))
+ {
+ si.setUseCallerIdentity(true);
+ }
+ }
+
+ public void setValue(Interceptor interceptor, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ interceptor.setInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelation relation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relation-name"))
+ {
+ relation.setEjbRelationName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbRelationshipRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-relationship-role-name"))
+ {
+ role.setEjbRelationshipRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("multiplicity"))
+ {
+ role.setMultiplicity(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RelationshipRoleSource source, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ source.setEjbName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CmrField field, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cmr-field-name"))
+ {
+ field.setCmrFieldName(getValue(localName, value));
+ }
+ else if (localName.equals("cmr-field-type"))
+ {
+ field.setCmrFieldType(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRole role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ role.setRoleName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MethodPermission permission, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+ permission.addRoleName(getValue(localName, value));
+ }
+ else if (localName.equals("unchecked"))
+ {
+ permission.setUnchecked(true);
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ContainerTransaction transaction, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("trans-attribute"))
+ {
+ transaction.setTransAttribute(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ method.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ method.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("lifecycle-callback-method"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Inject inject, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ inject.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(InterceptorBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ binding.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-class"))
+ {
+ binding.addInterceptorClass(getValue(localName, value));
+ }
+ else if (localName.equals("method-name"))
+ {
+ binding.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("method-param"))
+ {
+ binding.addMethodParam(getValue(localName, value));
+ }
+ else if (localName.equals("exclude-default-interceptors"))
+ {
+ binding.setExcludeDefaultInterceptors(true);
+ }
+ else if (localName.equals("exclude-class-interceptors"))
+ {
+ binding.setExcludeClassInterceptors(true);
+ }
+ }
+
+ public void setValue(InterceptorOrder order, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("interceptor-class"))
+ {
+ order.addInterceptorClass(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/EnterpriseBeans.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,352 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
+ * schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * ejbs.setCurrentEjbName(value); } else if
+ * (localName.equals("jndi-name")){ ejbs.setJndiName(value);
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class EnterpriseBeans
+{
+ private static final Logger log = Logger.getLogger(EnterpriseBeans.class);
+
+ private HashMap<String, EnterpriseBean> enterpriseBeans = new HashMap();
+
+ private EnterpriseBean currentEjb;
+
+ public void setPoolConfig(PoolConfig config)
+ {
+ currentEjb.setPoolConfig(config);
+ }
+
+ public void setDefaultActivationConfig(ActivationConfig config)
+ {
+ ((MessageDrivenBean)currentEjb).setDefaultActivationConfig(config);
+ }
+
+ public void setCacheConfig(CacheConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setCacheConfig(config);
+ }
+
+ public void setClustered(String clustered)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClustered(clustered);
+ }
+
+ public void setConcurrent(String concurrent)
+ {
+ ((SessionEnterpriseBean)currentEjb).setConcurrent(concurrent);
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ currentEjb.addJndiRef(ref);
+ }
+
+ public void addXmlAnnotation(XmlAnnotation xmlAnnotation)
+ {
+ currentEjb.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addRemoteBinding(RemoteBinding binding)
+ {
+ currentEjb.addRemoteBinding(binding);
+ }
+
+ public void addIgnoreDependency(InjectionTarget ignore)
+ {
+ currentEjb.addIgnoreDependency(ignore);
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ currentEjb.mergeResourceRef(ref);
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.mergeResourceEnvRef(ref);
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.mergeMessageDestinationRef(ref);
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ currentEjb.addServiceRef(ref);
+ }
+
+ public void setMethodAttributes(MethodAttributes attributes)
+ {
+ currentEjb.setMethodAttributes(attributes);
+ }
+
+ public void setCurrentEjbName(String currentEjbName, Class ejbClass)
+ {
+ currentEjb = createEjbByEjbName(currentEjbName, ejbClass);
+ }
+
+ public void addDependency(String depends)
+ {
+ currentEjb.addDependency(depends);
+ }
+
+ public void updateEjbRef(EjbRef ref)
+ {
+ currentEjb.updateEjbRef(ref);
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef ref)
+ {
+ currentEjb.updateEjbLocalRef(ref);
+ }
+
+ public void updateResourceRef(ResourceRef ref)
+ {
+ currentEjb.updateResourceRef(ref);
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef ref)
+ {
+ currentEjb.updateResourceEnvRef(ref);
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef ref)
+ {
+ currentEjb.updateMessageDestinationRef(ref);
+ }
+
+ public void setResourceAdapterName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setResourceAdaptorName(name);
+ }
+
+ public void setDestinationJndiName(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setDestinationJndiName(name);
+ }
+
+ public void setMdbUser(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbUser(name);
+ }
+
+ public void setMdbPassword(String name)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbPassword(name);
+ }
+
+ public void setMdbSubscriptionId(String id)
+ {
+ ((MessageDrivenBean)currentEjb).setMdbSubscriptionId(id);
+ }
+
+ public void setAopDomainName(String aopDomainName)
+ {
+ currentEjb.setAopDomainName(aopDomainName);
+ }
+
+ public void setRunAsPrincipal(String principal)
+ {
+ currentEjb.setRunAsPrincipal(principal);
+ }
+
+ public void setClusterConfig(ClusterConfig config)
+ {
+ ((SessionEnterpriseBean)currentEjb).setClusterConfig(config);
+ }
+
+ public void setCallByValue(boolean callByValue)
+ {
+ currentEjb.setCallByValue(callByValue);
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ currentEjb.setJndiName(jndiName);
+ }
+
+ public void setHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setHomeJndiName(homeJndiName);
+ }
+
+ public void setSecurityDomain(String securityDomain)
+ {
+ currentEjb.setSecurityDomain(securityDomain);
+ }
+
+ public void setLocalJndiName(String jndiName)
+ {
+ currentEjb.setLocalJndiName(jndiName);
+ }
+
+ public void setLocalHomeJndiName(String homeJndiName)
+ {
+ currentEjb.setLocalHomeJndiName(homeJndiName);
+ }
+
+ public EnterpriseBean createEjbByEjbName(String ejbName, Class ejbClass)
+ {
+ EnterpriseBean ejb = (EnterpriseBean) enterpriseBeans.get(ejbName);
+ if (ejb != null)
+ return ejb;
+
+ try
+ {
+ ejb = (EnterpriseBean)ejbClass.newInstance();
+ ejb.setEjbName(ejbName);
+ enterpriseBeans.put(ejbName, ejb);
+ }
+ catch (Exception e){}
+
+ return ejb;
+ }
+
+ public EnterpriseBean findEjbByEjbName(String ejbName)
+ {
+ return enterpriseBeans.get(ejbName);
+ }
+
+ public List<EnterpriseBean> findEjbsByClass(String className)
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>();
+
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ String ejbClassName = ejb.getEjbClass();
+ if (ejbClassName != null && ejbClassName.equals(className))
+ result.add(ejb);
+ }
+ return result;
+ }
+
+ public List<EnterpriseBean> findEjbs()
+ {
+ ArrayList<EnterpriseBean> result = new ArrayList<EnterpriseBean>(enterpriseBeans.values().size());
+
+ Iterator<EnterpriseBean> ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ result.add(ejbs.next());
+ }
+ return result;
+ }
+
+ public EnterpriseBean findEjbByRemote(String remote)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getRemote() != null && ejb.getRemote().equals(remote))
+ return ejb;
+ }
+ return null;
+ }
+
+ public EnterpriseBean findEjbByLocal(String local)
+ {
+ Iterator ejbs = enterpriseBeans.values().iterator();
+ while (ejbs.hasNext())
+ {
+ EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
+ if (ejb.getLocal() != null && ejb.getLocal().equals(local))
+ return ejb;
+ }
+ return null;
+ }
+
+ public Collection<EnterpriseBean> getEnterpriseBeans()
+ {
+ return enterpriseBeans.values();
+ }
+
+/* public void setEnterpriseBeans(List enterpriseBeans)
+ {
+ this.enterpriseBeans = enterpriseBeans;
+ }*/
+
+ public void addEnterpriseBean(EnterpriseBean ejb)
+ {
+ enterpriseBeans.put(ejb.getEjbName(), ejb);
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append("[");
+ sb.append("enterpriseBeans=").append(enterpriseBeans);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ return true;
+ if (!(o instanceof EnterpriseBeans))
+ return false;
+
+ final EnterpriseBeans ejbs = (EnterpriseBeans) o;
+
+ if (enterpriseBeans != null ? !enterpriseBeans
+ .equals(ejbs.enterpriseBeans) : ejbs.enterpriseBeans != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (enterpriseBeans != null ? enterpriseBeans.hashCode() : 0);
+ // result = 29 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/Injectable.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/Injectable.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/Injectable.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,62 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 69712 $
+ */
+public interface Injectable
+{
+
+ Collection<EjbLocalRef> getEjbLocalRefs();
+
+ Collection<EjbRef> getEjbRefs();
+
+ Collection<ResourceEnvRef> getResourceEnvRefs();
+
+ Collection<ResourceRef> getResourceRefs();
+
+ Collection<ServiceRefMetaData> getServiceRefs();
+
+ Collection<MessageDestinationRef> getMessageDestinationRefs();
+
+ List<PersistenceUnitRef> getPersistenceUnitRefs();
+
+ List<PersistenceContextRef> getPersistenceContextRefs();
+
+ Collection<JndiRef> getJndiRefs();
+}
\ No newline at end of file
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * A JBossXB object factory for parsing JBoss application client descriptor files.
+ *
+ * http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossClientDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossClientDDObjectFactory.class);
+
+ private ApplicationClientDD dd;
+
+ public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException
+ {
+ // TODO: how to properly fix this
+ if (dd == null)
+ dd = new ApplicationClientDD();
+
+ if (ddResource == null)
+ return dd;
+
+ log.debug("found jboss-client.xml " + ddResource);
+
+ JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+
+ return dd;
+ }
+
+ public JBossClientDDObjectFactory(ApplicationClientDD dd)
+ {
+ // JBossXB will otherwise fail later on
+ if (dd == null)
+ throw new NullPointerException("dd is null");
+
+ this.dd = dd;
+ }
+
+ public void addChild(ApplicationClientDD parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateEjbRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateMessageDestinationRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.addServiceRef(ref);
+ }
+
+ public void addChild(ApplicationClientDD dd, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceEnvRef(envRef);
+ }
+
+ public void addChild(ApplicationClientDD parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ dd.updateResourceRef(ref);
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext navigator, String uri, String name)
+ {
+ return root;
+ }
+
+ public Object newChild(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ child = newEnvRefGroupChild(localName);
+ if (child != null)
+ return child;
+
+ // space for more
+
+ return child;
+ }
+
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public void setValue(ApplicationClientDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ dd.setJndiName(value);
+ else if (localName.equals("depends"))
+ dd.addDependency(value);
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1086 @@
+/*
+ * 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.ejb3.metamodel;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.JndiRef;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
+import org.jboss.security.SecurityRoleMetaData;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.util.StringPropertyReplacer;
+import org.xml.sax.Attributes;
+
+/**
+ * Represents the jboss.xml deployment descriptor for the 2.1 schema
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @author Anil.Saldhana at jboss.com
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public class JBossDDObjectFactory extends DDObjectFactory
+{
+ private static final Logger log = Logger.getLogger(JBossDDObjectFactory.class);
+
+ private EjbJarDD dd;
+ private Class ejbClass;
+
+ public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException
+ {
+ ObjectModelFactory factory = null;
+ Unmarshaller unmarshaller = null;
+
+ if (ddResource != null)
+ {
+ log.debug("found jboss.xml " + ddResource);
+
+ if (dd == null)
+ dd = new EjbJarDD();
+
+ factory = new JBossDDObjectFactory(dd);
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setEntityResolver(new JBossEntityResolver());
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setValidation(true);
+
+ dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null);
+ }
+
+ return dd;
+ }
+
+ public JBossDDObjectFactory(EjbJarDD dd)
+ {
+ super();
+ this.dd = dd;
+ }
+
+ /**
+ * Return the root.
+ */
+ public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return dd;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("enterprise-beans"))
+ {
+ child = dd.getEnterpriseBeans();
+ if (child == null)
+ {
+ dd.setEnterpriseBeans(new EnterpriseBeans());
+ child = dd.getEnterpriseBeans();
+ }
+ }
+ else if (localName.equals("assembly-descriptor"))
+ {
+ child = dd.getAssemblyDescriptor();
+ if (child == null)
+ {
+ dd.setAssemblyDescriptor(new AssemblyDescriptor());
+ child = dd.getAssemblyDescriptor();
+ }
+ }
+ else if (localName.equals("resource-manager"))
+ {
+ child = new ResourceManager();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("current-message"))
+ {
+ child = new CurrentMessage();
+ }
+ else if (localName.equals("message-properties"))
+ {
+ child = new MessageProperties();
+ }
+ else if (localName.equals("producer"))
+ {
+ child = new Producer(false);
+ }
+ else if (localName.equals("local-producer"))
+ {
+ child = new Producer(true);
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ return child;
+
+ if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("method"))
+ {
+ child = new Method();
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(AssemblyDescriptor descriptor, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("message-destination"))
+ {
+ child = new MessageDestination();
+ }
+ if (localName.equals("security-role"))
+ {
+ child = new SecurityRoleMetaData("dummy_to_be_replaced_in_setValue");
+ }
+
+ return child;
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if ((child = this.newEnvRefGroupChild(localName)) != null)
+ {
+ return child;
+ }
+
+ if (localName.equals("session"))
+ {
+ ejbClass = SessionEnterpriseBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("message-driven"))
+ {
+ ejbClass = MessageDrivenBean.class;
+ child = ejbs;
+ }
+ else if (localName.equals("service"))
+ {
+ child = new Service();
+ }
+ else if (localName.equals("consumer"))
+ {
+ child = new Consumer();
+ }
+ else if (localName.equals("method-attributes"))
+ {
+ child = new MethodAttributes();
+ }
+ else if (localName.equals("annotation"))
+ {
+ child = new XmlAnnotation();
+ }
+ else if (localName.equals("ignore-dependency"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("cluster-config"))
+ {
+ child = new ClusterConfig();
+ }
+ else if (localName.equals("remote-binding"))
+ {
+ child = new RemoteBinding();
+ }
+ else if (localName.equals("cache-config"))
+ {
+ child = new CacheConfig();
+ }
+ else if (localName.equals("pool-config"))
+ {
+ child = new PoolConfig();
+ }
+ else if (localName.equals("default-activation-config"))
+ {
+ child = new ActivationConfig();
+ }
+
+ return child;
+ }
+
+ public Object newChild(ActivationConfig parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("default-activation-config-property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public Object newChild(XmlAnnotation parent, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("injection-target"))
+ {
+ child = new InjectionTarget();
+ }
+ else if (localName.equals("property"))
+ {
+ child = new NameValuePair();
+ }
+
+ return child;
+ }
+
+ public void addChild(XmlAnnotation parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addProperty(property);
+ }
+
+ public void addChild(XmlAnnotation parent, InjectionTarget injectionTarget, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setInjectionTarget(injectionTarget);
+ }
+
+ public void addChild(EnterpriseBeans parent, ActivationConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setDefaultActivationConfig(config);
+ }
+
+ public void addChild(ActivationConfig parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addActivationConfigProperty(property);
+ }
+
+ public void addChild(Consumer parent, Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ if (producer.isLocal())
+ parent.addLocalProducer(producer);
+ else parent.addProducer(producer);
+ }
+
+ public void addChild(Consumer parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(AssemblyDescriptor parent, MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMessageDestination(destination);
+ }
+
+ public void addChild(AssemblyDescriptor parent, SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRoleMetaData(srm);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCacheConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MethodAttributes attributes, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMethodAttributes(attributes);
+ }
+
+ public void addChild(EnterpriseBeans parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ public void addChild(EnterpriseBeans parent, InjectionTarget ignoreDependency, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addIgnoreDependency(ignoreDependency);
+ }
+
+ public void addChild(EnterpriseBeans parent, XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addXmlAnnotation(xmlAnnotation);
+ }
+
+ public void addChild(MethodAttributes parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ public void addChild(Consumer parent, CurrentMessage message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setCurrentMessage(message);
+ }
+
+ public void addChild(Consumer parent, PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setPoolConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, MessageProperties message, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setMessageProperties(message);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(CurrentMessage parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(MessageProperties parent, Method method, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addMethod(method);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Service service, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(service);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addRemoteBinding(binding);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Service parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Consumer parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceEnvRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addEnterpriseBean(consumer);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addJndiRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EjbJarDD parent, ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addResourceManager(manager);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, EjbLocalRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateEjbLocalRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setClusterConfig(config);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, MessageDestinationRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateMessageDestinationRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addServiceRef(ref);
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(EnterpriseBeans parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.updateResourceEnvRef(ref);
+ }
+
+ public void setValue(XmlAnnotation xmlAnnotation, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("annotation-class"))
+ {
+ xmlAnnotation.setAnnotationClass(getValue(localName, value));
+ }
+ else if (localName.equals("annotation-implementation-class"))
+ {
+ xmlAnnotation.setAnnotationImplementationClass(getValue(localName, value));
+ }
+ }
+
+ public void setValue(NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("activation-config-property-name") || localName.equals("message-driven-config-property-name") || localName.equals("property-name"))
+ {
+ property.setName(getValue(localName, value));
+ }
+ else if (localName.equals("activation-config-property-value") || localName.equals("message-driven-config-property-value") || localName.equals("property-value"))
+ {
+ property.setValue(getValue(localName, value));
+ }
+ }
+
+ public void setValue(ResourceManager manager, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("res-name"))
+ {
+ manager.setResourceName(getValue(localName, value));
+ }
+ else if (localName.equals("res-jndi-name"))
+ {
+ manager.setResourceJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(MessageDestination destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination-name"))
+ {
+ destination.setMessageDestinationName(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ destination.setJndiName(getValue(localName, value));
+ }
+ }
+
+ public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ ejbs.setCurrentEjbName(value, ejbClass);
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ ejbs.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("home-jndi-name"))
+ {
+ ejbs.setHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ ejbs.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-home-jndi-name"))
+ {
+ ejbs.setLocalHomeJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ ejbs.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ ejbs.addDependency(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ ejbs.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ ejbs.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("resource-adapter-name"))
+ {
+ ejbs.setResourceAdapterName(getValue(localName, value));
+ }
+ else if (localName.equals("destination-jndi-name"))
+ {
+ ejbs.setDestinationJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-user"))
+ {
+ ejbs.setMdbUser(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-passwd"))
+ {
+ ejbs.setMdbPassword(getValue(localName, value));
+ }
+ else if (localName.equals("mdb-subscription-id"))
+ {
+ ejbs.setMdbSubscriptionId(getValue(localName, value));
+ }
+ else if (localName.equals("clustered"))
+ {
+ ejbs.setClustered(getValue(localName, value));
+ }
+ else if (localName.equals("concurrent"))
+ {
+ ejbs.setConcurrent(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Service service, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("ejb-name"))
+ {
+ service.setEjbName(getValue(localName, value));
+ }
+ if (localName.equals("object-name"))
+ {
+ service.setObjectName(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ service.setEjbClass(getValue(localName, value));
+ }
+ if (localName.equals("xmbean"))
+ {
+ service.setXMBean(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ service.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ service.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("management"))
+ {
+ service.setManagement(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ service.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ service.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ service.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ service.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ service.addDependency(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Consumer consumer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("message-destination"))
+ {
+ consumer.setDestination(getValue(localName, value));
+ }
+ else if (localName.equals("message-destination-type"))
+ {
+ consumer.setDestinationType(getValue(localName, value));
+ }
+ else if (localName.equals("ejb-class"))
+ {
+ consumer.setEjbClass(getValue(localName, value));
+ consumer.setEjbName(getValue(localName, value));
+ }
+ else if (localName.equals("local"))
+ {
+ consumer.setLocal(getValue(localName, value));
+ }
+ else if (localName.equals("remote"))
+ {
+ consumer.setRemote(getValue(localName, value));
+ }
+ else if (localName.equals("jndi-name"))
+ {
+ consumer.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("local-jndi-name"))
+ {
+ consumer.setLocalJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("security-domain"))
+ {
+ consumer.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("run-as-principal"))
+ {
+ consumer.setRunAsPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("aop-domain-name"))
+ {
+ consumer.setAopDomainName(getValue(localName, value));
+ }
+ else if (localName.equals("depends"))
+ {
+ consumer.addDependency(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(RemoteBinding binding, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("jndi-name"))
+ {
+ binding.setJndiName(getValue(localName, value));
+ }
+ else if (localName.equals("client-bind-url"))
+ {
+ binding.setClientBindUrl(getValue(localName, value));
+ }
+ else if (localName.equals("proxy-factory"))
+ {
+ binding.setProxyFactory(getValue(localName, value));
+ }
+ else if (localName.equals("interceptor-stack"))
+ {
+ binding.setInterceptorStack(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(MessageProperties properties, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("delivery"))
+ {
+ properties.setDelivery(getValue(localName, value));
+ }
+ else if (localName.equals("class"))
+ {
+ properties.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("priority"))
+ {
+ properties.setPriority(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(ClusterConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("load-balance-policy"))
+ {
+ config.setLoadBalancePolicy(getValue(localName, value));
+ }
+ else if (localName.equals("partition-name"))
+ {
+ config.setPartition(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(CacheConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("cache-class"))
+ {
+ config.setCacheClass(getValue(localName, value));
+ }
+ else if (localName.equals("cache-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("idle-timeout-seconds"))
+ {
+ config.setIdleTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("remove-timeout-seconds"))
+ {
+ config.setRemoveTimeoutSeconds(getValue(localName, value));
+ }
+ else if (localName.equals("cache-name"))
+ {
+ config.setName(getValue(localName, value));
+ }
+ else if (localName.equals("persistence-manager"))
+ {
+ config.setPersistenceManager(getValue(localName, value));
+ }
+ else if (localName.equals("replication-is-passivation"))
+ {
+ config.setReplicationIsPassivation(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(PoolConfig config, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("pool-class"))
+ {
+ config.setPoolClass(getValue(localName, value));
+ }
+ else if (localName.equals("pool-max-size"))
+ {
+ config.setMaxSize(getValue(localName, value));
+ }
+ else if (localName.equals("pool-timeout"))
+ {
+ config.setTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Method method, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("method-name"))
+ {
+ method.setMethodName(getValue(localName, value));
+ }
+ else if (localName.equals("transaction-timeout"))
+ {
+ method.setTransactionTimeout(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(EjbJarDD dd, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("security-domain"))
+ {
+ dd.setSecurityDomain(getValue(localName, value));
+ }
+ else if (localName.equals("unauthenticated-principal"))
+ {
+ dd.setUnauthenticatedPrincipal(getValue(localName, value));
+ }
+ else if (localName.equals("jmx-name"))
+ {
+ dd.setJmxName(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(Producer producer, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("class"))
+ {
+ producer.setClassName(getValue(localName, value));
+ }
+ else if (localName.equals("connection-factory"))
+ {
+ producer.setConnectionFactory(getValue(localName, value));
+ }
+ }
+
+ /**
+ * Called when a child element with simple content is read for DD.
+ */
+ public void setValue(SecurityRoleMetaData srm, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (localName.equals("role-name"))
+ {
+// FIXME: NYI
+// srm.setRoleName(getValue(localName, value));
+ throw new RuntimeException("NYI");
+ }
+ else if (localName.equals("principal-name"))
+ {
+ srm.addPrincipalName(getValue(localName, value));
+ }
+ }
+
+ // may want to run StringPropertyReplacer on the whole descriptor at once
+ protected String getValue(String name, String value)
+ {
+ if (value.contains("${"))
+ {
+ String replacement = StringPropertyReplacer.replaceProperties(value);
+ if (replacement != null)
+ value = replacement;
+ }
+ return value;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefHandler.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefHandler.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,151 @@
+/*
+ * 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.injection;
+
+// $Id: WebServiceRefHandler.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Handle @WebServiceRef annotations
+ *
+ * @author Thomas.Diesler at jboss.com
+ */
+public class WebServiceRefHandler implements InjectionHandler
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
+ private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
+
+ public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ {
+ if (xml == null) return;
+ if (xml.getServiceRefs() == null) return;
+ for (ServiceRefMetaData sref : xml.getServiceRefs())
+ {
+ log.debug("@WebServiceRef override: " + sref);
+ if (srefMap.get(sref.getServiceRefName()) != null)
+ throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
+
+ srefMap.put(sref.getServiceRefName(), sref);
+ }
+ }
+
+ public void handleClassAnnotations(Class type, InjectionContainer container)
+ {
+ WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
+ if (wsref != null)
+ {
+ bindRefOnType(type, container, wsref);
+ }
+
+ WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
+ if (refs != null)
+ {
+ for (WebServiceRef refItem : refs.value())
+ {
+ bindRefOnType(type, container, refItem);
+ }
+ }
+ }
+
+ private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
+ {
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(type).substring(4);
+
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ String encName = "env/" + name;
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
+ }
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ if (!method.getName().startsWith("set"))
+ throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(method).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
+ }
+
+ injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
+ if (wsref == null) return;
+
+ String name = wsref.name();
+ if (name.equals(""))
+ name = InjectionUtil.getEncName(field).substring(4);
+
+ String encName = "env/" + name;
+ Context encCtx = container.getEnc();
+ if (!container.getEncInjectors().containsKey(name))
+ {
+ ServiceRefMetaData sref = getServiceRefForName(name);
+ container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
+ }
+
+ injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
+ }
+
+ private ServiceRefMetaData getServiceRefForName(String name)
+ {
+ ServiceRefMetaData sref = srefMap.get(name);
+ if (sref == null)
+ {
+ log.debug("No override for @WebServiceRef.name: " + name);
+ sref = new ServiceRefDelegate().newServiceRefMetaData();
+ sref.setServiceRefName(name);
+ }
+ return sref;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefInjector.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/injection/WebServiceRefInjector.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,84 @@
+/*
+ * 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.injection;
+
+// $Id: WebServiceRefInjector.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.wsf.common.URLLoaderAdapter;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * Inject a jaxws web service ref.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision: 69712 $
+ */
+public class WebServiceRefInjector implements EncInjector
+{
+ private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
+
+ private String name;
+ private ServiceRefMetaData sref;
+
+ public WebServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
+ {
+ this.name = name;
+ this.sref = sref;
+ this.sref.setAnnotatedElement(anElement);
+ }
+
+ public void inject(InjectionContainer container)
+ {
+ try
+ {
+ Context encCtx = container.getEnc();
+ EJBContainer ejbContainer = (EJBContainer)container;
+ DeploymentUnit unit = ejbContainer.getDeploymentUnit();
+ URL rootURL = unit.getUrl();
+
+ ClassLoader loader = unit.getClassLoader();
+ URLLoaderAdapter vfsRoot = new URLLoaderAdapter(rootURL);
+ new ServiceRefDelegate().bindServiceRef(encCtx, name, vfsRoot, loader, sref);
+
+ log.debug("@WebServiceRef bound [env=" + name + "]");
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + "]", e);
+ }
+ }
+
+ public String toString()
+ {
+ return super.toString() + "{enc=" + name + "}";
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/43specific/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,241 @@
+/*
+ * 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.metamodel.descriptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version <tt>$Revision: 69712 $</tt>
+ */
+public abstract class EnvironmentRefGroup
+{
+ private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class);
+
+ protected HashMap<String, EjbLocalRef> ejbLocalRefs = new HashMap<String, EjbLocalRef>();
+ protected HashMap<String, EjbRef> ejbRefs = new HashMap<String, EjbRef>();
+ protected HashMap<String, EnvEntry> envEntries = new HashMap<String, EnvEntry>();
+ protected HashMap<String, ResourceEnvRef> resourceEnvRefs = new HashMap<String, ResourceEnvRef>();
+ protected HashMap<String, ResourceRef> resourceRefs = new HashMap<String, ResourceRef>();
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
+ /** An index of MessageDestinationRef keyed by message-destination-link values */
+ protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
+ protected HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
+ protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
+ protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
+ protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
+
+ public Collection<MessageDestinationRef> getMessageDestinationRefs()
+ {
+ return messageDestinationRefs.values();
+ }
+
+ public void addMessageDestinationRef(MessageDestinationRef ref)
+ {
+ log.debug("addMessageDestinationRef, "+ref);
+ messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref);
+ String link = ref.getMessageDestinationLink();
+ if( link != null )
+ {
+ messageDestinationRefsByLink.put(link, ref);
+ }
+ }
+
+ public Collection<EjbLocalRef> getEjbLocalRefs()
+ {
+ return ejbLocalRefs.values();
+ }
+
+ public void addEjbLocalRef(EjbLocalRef ref)
+ {
+ ejbLocalRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EjbRef> getEjbRefs()
+ {
+ return ejbRefs.values();
+ }
+
+ public void addEjbRef(EjbRef ref)
+ {
+ ejbRefs.put(ref.getEjbRefName(), ref);
+ }
+
+ public Collection<EnvEntry> getEnvEntries()
+ {
+ return envEntries.values();
+ }
+
+ public void addEnvEntry(EnvEntry entry)
+ {
+ envEntries.put(entry.getEnvEntryName(), entry);
+ }
+
+ public Collection<ResourceEnvRef> getResourceEnvRefs()
+ {
+ return resourceEnvRefs.values();
+ }
+
+ public void addResourceEnvRef(ResourceEnvRef envRef)
+ {
+ resourceEnvRefs.put(envRef.getResRefName(), envRef);
+ }
+
+ public Collection<ResourceRef> getResourceRefs()
+ {
+ return resourceRefs.values();
+ }
+
+ public void addResourceRef(ResourceRef ref)
+ {
+ resourceRefs.put(ref.getResRefName(), ref);
+ }
+
+ public Collection<JndiRef> getJndiRefs()
+ {
+ return jndiRefs.values();
+ }
+
+ public void addJndiRef(JndiRef ref)
+ {
+ jndiRefs.put(ref.getJndiRefName(), ref);
+ }
+
+ public Collection<ServiceRefMetaData> getServiceRefs()
+ {
+ return serviceRefs.values();
+ }
+
+ public void addServiceRef(ServiceRefMetaData ref)
+ {
+ serviceRefs.put(ref.getServiceRefName(), ref);
+ }
+
+ public void updateEjbRef(EjbRef updatedRef)
+ {
+ EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateEjbLocalRef(EjbLocalRef updatedRef)
+ {
+ EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
+ }
+ else
+ {
+ ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceRef(ResourceRef updatedRef)
+ {
+ ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ ref.setResUrl(updatedRef.getResUrl());
+ ref.setResourceName(updatedRef.getResourceName());
+ }
+ else
+ {
+ resourceRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateResourceEnvRef(ResourceEnvRef updatedRef)
+ {
+ ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef);
+ }
+ }
+
+ public void updateMessageDestinationRef(MessageDestinationRef updatedRef)
+ {
+ log.debug("updateMessageDestinationRef, "+updatedRef);
+ MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName());
+ if (ref != null)
+ {
+ ref.setMappedName(updatedRef.getMappedName());
+ }
+ else
+ {
+ messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef);
+ ref = updatedRef;
+ }
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ return sb.toString();
+ }
+
+ public List<PersistenceContextRef> getPersistenceContextRefs()
+ {
+ return persistenceContextRefs;
+ }
+
+ public List<PersistenceUnitRef> getPersistenceUnitRefs()
+ {
+ return persistenceUnitRefs;
+ }
+
+ public void addPersistenceContextRef(PersistenceContextRef ref)
+ {
+ persistenceContextRefs.add(ref);
+ }
+
+ public void addPersistenceUnitRef(PersistenceUnitRef ref)
+ {
+ persistenceUnitRefs.add(ref);
+ }
+
+ public MessageDestinationRef getMessageDestinationRefForLink(String link)
+ {
+ MessageDestinationRef ref = messageDestinationRefsByLink.get(link);
+ return ref;
+ }
+}
Modified: branches/JBPAPP_4_2_0_GA_CP/server/build.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/build.xml 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/build.xml 2008-06-25 18:30:35 UTC (rev 75080)
@@ -87,6 +87,7 @@
<property name="javac.target" value="5"/>
<property name="javac.source" value="5"/>
+ <property name="source.version.specific" value="${module.output}/versionspecificcode"/>
<!-- ========= -->
<!-- Libraries -->
@@ -189,6 +190,15 @@
<property name="jca.connection.interceptor" value="<interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>"/>
<call target="_default:task-init"/>
+ <!-- Set it up so that the correct (4.2/4.3 specific) source is used -->
+ <condition property="version.specific.dir" value="${source.resources}/43specific" else="${source.resources}/42specific">
+ <isset property="build.soa.bits"/>
+ </condition>
+
+ <copy todir="${source.version.specific}">
+ <fileset dir="${version.specific.dir}"/>
+ </copy>
+
</target>
@@ -263,6 +273,7 @@
<src path="${source.java}"/>
<src path="${build.parsers}"/>
+ <src path="${source.version.specific}"/>
<exclude name="org/jboss/ejb/plugins/cmp/jdbc/jdbc3/*.java" unless="HAVE_JDK_1.4"/>
</javac>
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/deployment/ClientDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/deployment/ClientDeployer.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/deployment/ClientDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,332 +0,0 @@
-/*
- * 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.deployment;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NamingException;
-
-import org.jboss.ejb.EjbUtil;
-import org.jboss.metadata.ClientMetaData;
-import org.jboss.metadata.EjbRefMetaData;
-import org.jboss.metadata.EnvEntryMetaData;
-import org.jboss.metadata.ResourceEnvRefMetaData;
-import org.jboss.metadata.ResourceRefMetaData;
-import org.jboss.metadata.XmlFileLoader;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.common.URLLoaderAdapter;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.w3c.dom.Element;
-
-/**
- * An XMBean resource implementation of a deployer for j2ee application
- * client jars
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ClientDeployer extends SubDeployerSupport
-{
- protected void startService() throws Exception
- {
- // register with MainDeployer
- super.startService();
- }
-
- /**
- * Implements the template method in superclass. This method stops all the
- * applications in this server.
- */
- protected void stopService() throws Exception
- {
- // deregister with MainDeployer
- super.stopService();
- }
-
- /**
- * This method looks to the deployment for a META-INF/application-client.xml
- * descriptor to identify a j2ee client jar.
- *
- * @param di The deployment info instance for the jar
- * @return true if the deployment is a j2ee client jar, false otherwise
- */
- public boolean accepts(DeploymentInfo di)
- {
- // To be accepted the deployment's root name must end in jar
- String urlStr = di.url.getFile();
- if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".jar/"))
- {
- return false;
- }
-
- // However the jar must also contain an META-INF/application-client.xml
- boolean accepts = false;
- try
- {
- URL dd = di.localCl.findResource("META-INF/application-client.xml");
- if (dd != null)
- {
- log.debug("Found a META-INF/application-client.xml file, di: " + di);
- accepts = true;
- }
- }
- catch (Exception ignore)
- {
- }
-
- return accepts;
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'create' logic.
- * <p/>
- * This method issues a JMX notification of type SubDeployer.CREATE_NOTIFICATION.
- */
- public void create(DeploymentInfo di) throws DeploymentException
- {
- super.create(di);
- }
-
- /**
- * Parse the application-client.xml and jboss-client.xml descriptors.
- *
- * @param di the application client jar deployment info
- */
- public void start(DeploymentInfo di) throws DeploymentException
- {
- ClientMetaData metaData = null;
- try
- {
- InputStream in = null;
- if (di.alternativeDD == null)
- {
- in = di.localCl.getResourceAsStream("META-INF/application-client.xml");
- }
- else
- {
- String contentsDir = new File(di.url.getPath()).getParent();
- in = new FileInputStream(contentsDir + "/" + di.alternativeDD);
- }
-
- if (in == null)
- throw new DeploymentException("No META-INF/application-client.xml found");
-
- metaData = null;
- XmlFileLoader xfl = new XmlFileLoader(true);
- Element appClient = xfl.getDocument(in, "META-INF/application-client.xml").getDocumentElement();
- in.close();
- metaData = new ClientMetaData();
- metaData.setResourceClassLoader(di.localCl);
- metaData.importClientXml(appClient);
- di.metaData = metaData;
-
- // Look for a jboss-client.xml descriptor
- in = di.localCl.getResourceAsStream("META-INF/jboss-client.xml");
- if (in != null)
- {
- xfl = new XmlFileLoader(true);
- Element jbossClient = xfl.getDocument(in, "META-INF/jboss-client.xml").getDocumentElement();
- in.close();
- metaData.importJbossClientXml(jbossClient);
- }
- }
- catch (IOException e)
- {
- throw new DeploymentException("Failed to parse metadata", e);
- }
-
- try
- {
- setupEnvironment(di, metaData);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Failed to setup client ENC", e);
- }
-
- super.start(di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'stop' logic.
- * <p/>
- * This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.
- */
- public void stop(DeploymentInfo di) throws DeploymentException
- {
- // Teardown the JNDI context
- ClientMetaData metaData = (ClientMetaData) di.metaData;
- if (metaData != null)
- {
- String appClientName = metaData.getJndiName();
- log.info("Removing client ENC from: " + appClientName);
- try
- {
- InitialContext iniCtx = new InitialContext();
- Util.unbind(iniCtx, appClientName);
- }
- catch (NamingException e)
- {
- throw new DeploymentException("Failed to remove client ENC", e);
- }
- }
- super.stop(di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'destroy' logic.
- * <p/>
- * This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION.
- */
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- super.destroy(di);
- }
-
- private void setupEnvironment(DeploymentInfo di, ClientMetaData metaData)
- throws Exception
- {
- // Setup a JNDI context which contains
- String appClientName = metaData.getJndiName();
- InitialContext iniCtx = new InitialContext();
- Context envCtx = Util.createSubcontext(iniCtx, appClientName);
- log.debug("Creating client ENC binding under: " + appClientName);
- // Bind environment properties
- Iterator i = metaData.getEnvironmentEntries().iterator();
- while (i.hasNext())
- {
- EnvEntryMetaData entry = (EnvEntryMetaData) i.next();
- log.debug("Binding env-entry: " + entry.getName() + " of type: " +
- entry.getType() + " to value:" + entry.getValue());
- EnvEntryMetaData.bindEnvEntry(envCtx, entry);
- }
-
- // Bind EJB references
- HashMap ejbRefs = metaData.getEjbReferences();
- i = ejbRefs.values().iterator();
- while (i.hasNext())
- {
- EjbRefMetaData ref = (EjbRefMetaData) i.next();
- log.debug("Binding an EJBReference " + ref.getName());
-
- if (ref.getLink() != null)
- {
- // Internal link
- String linkName = ref.getLink();
- String jndiName = EjbUtil.findEjbLink(server, di, linkName);
- log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName);
- if (jndiName == null)
- {
- String msg = "Failed to resolve ejb-link: " + linkName
- + " make by ejb-name: " + ref.getName();
- throw new DeploymentException(msg);
- }
- log.debug("Link resolved to:" + jndiName);
- Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
- }
- else
- {
- // Bind the bean level ejb-ref/jndi-name
- if (ref.getJndiName() == null)
- {
- throw new DeploymentException("ejb-ref " + ref.getName() +
- ", expected either ejb-link in ejb-jar.xml " +
- "or jndi-name in jboss.xml");
- }
- log.debug("Binding " + ref.getName() + " to : " + ref.getJndiName());
- Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
- }
- }
-
- // Bind service references
- UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
- for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
- {
- String refName = sref.getServiceRefName();
- new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
- }
-
- // Bind resource references
- HashMap resRefs = metaData.getResourceReferences();
- i = resRefs.values().iterator();
- while (i.hasNext())
- {
- ResourceRefMetaData ref = (ResourceRefMetaData) i.next();
- String refName = ref.getRefName();
- String jndiName = ref.getJndiName();
-
- if (ref.getType().equals("java.net.URL"))
- {
- // URL bindings
- 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);
- }
- }
- else
- {
- // A resource link
- log.debug("Binding resource: " + refName + " to JDNI as: " + jndiName);
- Util.bind(envCtx, refName, new LinkRef(jndiName));
- }
- }
-
- // Bind resource env references
- HashMap envRefs = metaData.getResourceEnvReferences();
- i = envRefs.values().iterator();
- while (i.hasNext())
- {
- ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData) i.next();
- String encName = resRef.getRefName();
- String jndiName = resRef.getJndiName();
- // Should validate the type...
- log.debug("Binding env resource: " + encName +
- " to JDNI as: " + jndiName);
- Util.bind(envCtx, encName, new LinkRef(jndiName));
- }
- log.info("Client ENC bound under: " + appClientName);
- }
-}
-
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/Container.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/Container.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/ejb/Container.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,1602 +0,0 @@
-/*
- * 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;
-
-// $Id$
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.rmi.MarshalException;
-import java.security.AccessController;
-import java.security.Policy;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.EJBException;
-import javax.ejb.EJBObject;
-import javax.ejb.TimedObject;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.ejb.spi.HandleDelegate;
-import javax.management.MBeanException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-import javax.transaction.TransactionManager;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.ejb.plugins.local.BaseLocalProxyFactory;
-import org.jboss.ejb.txtimer.EJBTimerService;
-import org.jboss.invocation.Invocation;
-import org.jboss.invocation.InvocationKey;
-import org.jboss.invocation.InvocationStatistics;
-import org.jboss.invocation.InvocationType;
-import org.jboss.invocation.JBossLazyUnmarshallingException;
-import org.jboss.invocation.MarshalledInvocation;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ApplicationMetaData;
-import org.jboss.metadata.BeanMetaData;
-import org.jboss.metadata.EjbLocalRefMetaData;
-import org.jboss.metadata.EjbRefMetaData;
-import org.jboss.metadata.EnvEntryMetaData;
-import org.jboss.metadata.MessageDestinationMetaData;
-import org.jboss.metadata.MessageDestinationRefMetaData;
-import org.jboss.metadata.ResourceEnvRefMetaData;
-import org.jboss.metadata.ResourceRefMetaData;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.mx.util.ObjectNameConverter;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.security.AnybodyPrincipal;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.RealmMapping;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.util.NestedError;
-import org.jboss.util.NestedRuntimeException;
-import org.jboss.util.naming.ENCThreadLocalKey;
-import org.jboss.util.naming.NonSerializableFactory;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.common.URLLoaderAdapter;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.omg.CORBA.ORB;
-
-/**
- * This is the base class for all EJB-containers in JBoss. A Container
- * functions as the central hub of all metadata and plugins. Through this
- * the container plugins can get hold of the other plugins and any metadata
- * they need.
- *
- * <p>The EJBDeployer creates instances of subclasses of this class
- * and calls the appropriate initialization methods.
- *
- * <p>A Container does not perform any significant work, but instead delegates
- * to the plugins to provide for all kinds of algorithmic functionality.
- *
- * @see EJBDeployer
- *
- * @author <a href="mailto:rickard.oberg at jboss.org">Rickard �berg</a>
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
- * @author <a href="bill at burkecentral.com">Bill Burke</a>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:christoph.jung at infor.de">Christoph G. Jung</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- *
- * @jmx.mbean extends="org.jboss.system.ServiceMBean"
- */
-public abstract class Container extends ServiceMBeanSupport
- implements ContainerMBean, AllowedOperationsFlags
-{
- public final static String BASE_EJB_CONTAINER_NAME =
- "jboss.j2ee:service=EJB";
-
- public final static ObjectName ORB_NAME = ObjectNameFactory.create("jboss:service=CorbaORB");
-
- public final static ObjectName EJB_CONTAINER_QUERY_NAME =
- ObjectNameFactory.create(BASE_EJB_CONTAINER_NAME + ",*");
-
- protected static final Method EJBOBJECT_REMOVE;
- /** A reference to {@link javax.ejb.TimedObject#ejbTimeout}. */
- protected static final Method EJB_TIMEOUT;
-
- /** This is the application that this container is a part of */
- protected EjbModule ejbModule;
-
- /**
- * This is the local classloader of this container. Used for loading
- * resources that must come from the local jar file for the container.
- * NOT for loading classes!
- */
- protected ClassLoader localClassLoader;
-
- /**
- * This is the classloader of this container. All classes and resources that
- * the bean uses will be loaded from here. By doing this we make the bean
- * re-deployable
- */
- protected ClassLoader classLoader;
-
- /** The class loader for remote dynamic classloading */
- protected ClassLoader webClassLoader;
-
- /**
- * Externally supplied configuration data
- */
- private DeploymentInfo di;
-
- /**
- * This is the new metadata. it includes information from both ejb-jar and
- * jboss.xml the metadata for the application can be accessed trough
- * metaData.getApplicationMetaData()
- */
- protected BeanMetaData metaData;
-
- /** This is the EnterpriseBean class */
- protected Class beanClass;
-
- /** This is the Home interface class */
- protected Class homeInterface;
-
- /** This is the Remote interface class */
- protected Class remoteInterface;
-
- /** The local home interface class */
- protected Class localHomeInterface;
-
- /** The local inteface class */
- protected Class localInterface;
-
- /** This is the TransactionManager */
- protected TransactionManager tm;
-
- /** This is the SecurityManager */
- protected AuthenticationManager sm;
-
- /** This is the realm mapping */
- protected RealmMapping rm;
-
- /** The custom security proxy used by the SecurityInterceptor */
- protected Object securityProxy;
-
- /** This is the bean lock manager that is to be used */
- protected BeanLockManager lockManager;
-
- /** ??? */
- protected LocalProxyFactory localProxyFactory =
- new BaseLocalProxyFactory();
-
- /** This is a cache for method permissions */
- private HashMap methodPermissionsCache = new HashMap();
-
- /** Maps for MarshalledInvocation mapping */
- protected Map marshalledInvocationMapping = new HashMap();
-
- /** ObjectName of Container */
- private ObjectName jmxName;
- /** HashMap<String, EJBProxyFactory> for the invoker bindings */
- protected HashMap proxyFactories = new HashMap();
- /** A priviledged actions for MBeanServer.invoke when running with sec mgr */
- private MBeanServerAction serverAction = new MBeanServerAction();
-
- /**
- * The Proxy factory is set in the Invocation. This TL is used
- * for methods that do not have access to the Invocation.
- */
- protected ThreadLocal proxyFactoryTL = new ThreadLocal();
-
- /** The number of create invocations that have been made */
- protected long createCount;
- /** The number of create invocations that have been made */
- protected long removeCount;
- /** Time statistics for the invoke(Invocation) methods */
- protected InvocationStatistics invokeStats = new InvocationStatistics();
-
- /** The JACC context id for the container */
- protected String jaccContextID;
-
- /**
- * Flag to denote whether a JACC configuration has been fitted for authorization
- */
- protected boolean isJaccEnabled = false;
-
- static
- {
- try
- {
- EJBOBJECT_REMOVE = EJBObject.class.getMethod("remove", new Class[0]);
- EJB_TIMEOUT = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
- }
- catch (Throwable t)
- {
- throw new NestedRuntimeException(t);
- }
- }
-
- // Public --------------------------------------------------------
-
- public Class getLocalClass()
- {
- return localInterface;
- }
-
- public Class getLocalHomeClass()
- {
- return localHomeInterface;
- }
-
- public Class getRemoteClass()
- {
- return remoteInterface;
- }
-
- /**
- * this actually should be called remotehome, but for interface compliance purposes
- * we keep it like that
- */
- public Class getHomeClass()
- {
- return homeInterface;
- }
-
- /**
- * Whether the bean is call by value
- *
- * @return true for call by value
- */
- public boolean isCallByValue()
- {
- if (ejbModule.isCallByValue())
- return true;
- return metaData.isCallByValue();
- }
-
- /**
- * Sets a transaction manager for this container.
- *
- * @see javax.transaction.TransactionManager
- *
- * @param tm
- */
- public void setTransactionManager(final TransactionManager tm)
- {
- this.tm = tm;
- }
-
- /**
- * Returns this container's transaction manager.
- *
- * @return A concrete instance of javax.transaction.TransactionManager
- */
- public TransactionManager getTransactionManager()
- {
- return tm;
- }
-
- public void setSecurityManager(AuthenticationManager sm)
- {
- this.sm = sm;
- }
-
- public AuthenticationManager getSecurityManager()
- {
- return sm;
- }
-
- public BeanLockManager getLockManager()
- {
- return lockManager;
- }
-
- public void setLockManager(final BeanLockManager lockManager)
- {
- this.lockManager = lockManager;
- lockManager.setContainer(this);
- }
-
- public void addProxyFactory(String invokerBinding, EJBProxyFactory factory)
- {
- proxyFactories.put(invokerBinding, factory);
- }
-
- public void setRealmMapping(final RealmMapping rm)
- {
- this.rm = rm;
- }
-
- public RealmMapping getRealmMapping()
- {
- return rm;
- }
-
- public void setSecurityProxy(Object proxy)
- {
- this.securityProxy = proxy;
- }
-
- public Object getSecurityProxy()
- {
- return securityProxy;
- }
-
- public EJBProxyFactory getProxyFactory()
- {
- EJBProxyFactory factory = (EJBProxyFactory)proxyFactoryTL.get();
- // There's no factory thread local which means this is probably
- // a local invocation. Just use the first (usually only)
- // proxy factory.
- // TODO: define a default factory in the meta data or
- // even better, let the return over the original transport
- // plugin the transport layer for the generated proxy
- if (factory == null && remoteInterface != null)
- {
- Iterator i = proxyFactories.values().iterator();
- if (i.hasNext())
- factory = (EJBProxyFactory)i.next();
- }
- return factory;
- }
-
- public void setProxyFactory(Object factory)
- {
- proxyFactoryTL.set(factory);
- }
-
- public EJBProxyFactory lookupProxyFactory(String binding)
- {
- return (EJBProxyFactory)proxyFactories.get(binding);
- }
-
- /**
- * Gets the DeploymentInfo for this Container
- *
- * @return The DeploymentInfo for this Container
- */
- public final DeploymentInfo getDeploymentInfo()
- {
- return di;
- }
-
- /**
- * Sets the DeploymentInfo of this Container
- *
- * @param di The new DeploymentInfo to be used
- */
- public final void setDeploymentInfo(DeploymentInfo di)
- {
- this.di = di;
- }
-
- /**
- * Sets the application deployment unit for this container. All the bean
- * containers within the same application unit share the same instance.
- *
- * @param app application for this container
- */
- public void setEjbModule(EjbModule app)
- {
- ejbModule = app;
- }
-
- public String getJaccContextID()
- {
- return jaccContextID;
- }
-
- public void setJaccContextID(String id)
- {
- jaccContextID = id;
- }
-
- /**
- * Get the flag whether JACC is enabled
- * @return
- */
- public boolean isJaccEnabled()
- {
- return isJaccEnabled;
- }
-
- /**
- * Set the flag that JACC is enabled
- *
- * @param isJaccEnabled
- */
- public void setJaccEnabled(boolean isJaccEnabled)
- {
- this.isJaccEnabled = isJaccEnabled;
- }
-
- /**
- * Gets the application deployment unit for this container. All the bean
- * containers within the same application unit share the same instance.
- * @jmx.managed-attribute
- */
- public EjbModule getEjbModule()
- {
- return ejbModule;
- }
-
- /**
- * Gets the number of create invocations that have been made
- * @jmx.managed-attribute
- */
- public long getCreateCount()
- {
- return createCount;
- }
-
- /**
- * Gets the number of remove invocations that have been made
- * @jmx.managed-attribute
- */
- public long getRemoveCount()
- {
- return removeCount;
- }
-
- /** Gets the invocation statistics collection
- * @jmx.managed-attribute
- */
- public InvocationStatistics getInvokeStats()
- {
- return invokeStats;
- }
-
- /**
- * Sets the local class loader for this container.
- * Used for loading resources from the local jar file for this container.
- * NOT for loading classes!
- *
- * @param cl
- */
- public void setLocalClassLoader(ClassLoader cl)
- {
- this.localClassLoader = cl;
- }
-
- /**
- * Returns the local classloader for this container.
- *
- * @return The local classloader for this container.
- */
- public ClassLoader getLocalClassLoader()
- {
- return localClassLoader;
- }
-
- /**
- * Sets the class loader for this container. All the classes and resources
- * used by the bean in this container will use this classloader.
- *
- * @param cl
- */
- public void setClassLoader(ClassLoader cl)
- {
- this.classLoader = cl;
- }
-
- /**
- * Returns the classloader for this container.
- *
- * @return
- */
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-
- /** Get the class loader for dynamic class loading via http.
- */
- public ClassLoader getWebClassLoader()
- {
- return webClassLoader;
- }
-
- /** Set the class loader for dynamic class loading via http.
- */
- public void setWebClassLoader(final ClassLoader webClassLoader)
- {
- this.webClassLoader = webClassLoader;
- }
-
- /**
- * Sets the meta data for this container. The meta data consists of the
- * properties found in the XML descriptors.
- *
- * @param metaData
- */
- public void setBeanMetaData(final BeanMetaData metaData)
- {
- this.metaData = metaData;
- }
-
- /** Get the components environment context
- * @jmx.managed-attribute
- * @return Environment Context
- */
- public Context getEnvContext() throws NamingException
- {
- ClassLoader ccl = SecurityActions.getContextClassLoader();
- try
- {
- // The ENC is a map keyed on the class loader
- SecurityActions.setContextClassLoader(classLoader);
- return (Context)new InitialContext().lookup("java:comp/env");
- }
- finally
- {
- SecurityActions.setContextClassLoader(ccl);
- }
- }
-
- /**
- * Returns the metadata of this container.
- *
- * @jmx.managed-attribute
- * @return metaData;
- */
- public BeanMetaData getBeanMetaData()
- {
- return metaData;
- }
-
- /**
- * Returns the permissions for a method. (a set of roles)
- *
- * @return assemblyDescriptor;
- */
- public Set getMethodPermissions(Method m, InvocationType iface)
- {
- Set permissions;
-
- if (methodPermissionsCache.containsKey(m))
- {
- permissions = (Set) methodPermissionsCache.get(m);
- }
- else if( m.equals(EJB_TIMEOUT) )
- {
- // No role is required to access the ejbTimeout as this is
- permissions = new HashSet();
- permissions.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
- methodPermissionsCache.put(m, permissions);
- }
- else
- {
- String name = m.getName();
- Class[] sig = m.getParameterTypes();
- permissions = getBeanMetaData().getMethodPermissions(name, sig, iface);
- methodPermissionsCache.put(m, permissions);
- }
-
- return permissions;
- }
-
- /**
- * Returns the bean class instance of this container.
- *
- * @return instance of the Enterprise bean class.
- */
- public Class getBeanClass()
- {
- return beanClass;
- }
-
- /**
- * Returns a new instance of the bean class or a subclass of the bean class.
- * This factory style method is speciffically used by a container to supply
- * an implementation of the abstract accessors in EJB2.0, but could be
- * usefull in other situations. This method should ALWAYS be used instead
- * of getBeanClass().newInstance();
- *
- * @return the new instance
- *
- * @see java.lang.Class#newInstance
- */
- public Object createBeanClassInstance() throws Exception
- {
- return getBeanClass().newInstance();
- }
-
- /**
- * Sets the codebase of this container.
- *
- * @param codebase a possibly empty, but non null String with
- * a sequence of URLs separated by spaces
- * /
- public void setCodebase(final String codebase)
- {
- if (codebase != null)
- this.codebase = codebase;
- }
- */
- /**
- * Gets the codebase of this container.
- *
- * @return this container's codebase String, a sequence of URLs
- * separated by spaces
- * /
- public String getCodebase()
- {
- return codebase;
- }
- */
- /** Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName]
- where the [jndiName] is either the bean remote home JNDI binding, or
- the local home JNDI binding if the bean has no remote interfaces.
- */
- public ObjectName getJmxName()
- {
- if (jmxName == null)
- {
- BeanMetaData beanMetaData = getBeanMetaData();
- if (beanMetaData == null)
- {
- throw new IllegalStateException("Container metaData is null");
- }
-
- String jndiName = beanMetaData.getContainerObjectNameJndiName();
- if (jndiName == null)
- {
- throw new IllegalStateException("Container jndiName is null");
- }
-
- // The name must be escaped since the jndiName may be arbitrary
- String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName;
- try
- {
- jmxName = ObjectNameConverter.convert(name);
- }
- catch (MalformedObjectNameException e)
- {
- throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage());
- }
- }
- return jmxName;
- }
-
- /**
- * Creates the single Timer Service for this container if not already created
- *
- * @param pKey Bean id
- * @return Container Timer Service
- * @throws IllegalStateException If the type of EJB is not allowed to use the
- * timer service, or the bean class does not implement javax.ejb.TimedObject
- *
- * @see javax.ejb.EJBContext#getTimerService
- *
- * @jmx.managed-operation
- **/
- public TimerService getTimerService(Object pKey)
- throws IllegalStateException
- {
- if (this instanceof StatefulSessionContainer)
- throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService");
-
- // Validate that the bean implements the TimedObject interface
- Class beanClass = this.getBeanClass();
- if( TimedObject.class.isAssignableFrom(beanClass) == false )
- {
- String msg = this.getBeanMetaData().getEjbName()
- +" requested getTimerService but "+beanClass
- +" does not implement javax.ejb.TimedObject";
- throw new IllegalStateException(msg);
- }
-
- TimerService timerService = null;
- try
- {
- EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
- timerService = service.createTimerService(getJmxName(), pKey, this);
- }
- catch (Exception e)
- {
- throw new EJBException("Could not create timer service", e);
- }
- return timerService;
- }
-
- /**
- * Removes Timer Service for this container
- *
- * @param pKey Bean id
- * @throws IllegalStateException If the type of EJB is not allowed to use the timer service
- *
- * @jmx.managed-operation
- **/
- public void removeTimerService(Object pKey)
- throws IllegalStateException
- {
- try
- {
- EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
- if (pKey != null)
- {
- // entity bean->remove()
- service.removeTimerService(getJmxName(), pKey);
- }
- else
- {
- // container stop, we choose whether active timers
- // should be persisted (default), or not (legacy)
- service.removeTimerService(getJmxName(), getBeanMetaData().getTimerPersistence());
- }
- }
- catch (Exception e)
- {
- log.error("Could not remove timer service", e);
- }
- }
-
- /**
- * Restore any timers previously persisted for this container
- */
- protected void restoreTimers()
- {
- try
- {
- // pass to the ejb timer service the container ObjectName
- server.invoke(
- EJBTimerService.OBJECT_NAME,
- "restoreTimers",
- new Object[] { getServiceName(), getClassLoader() },
- new String[] { "javax.management.ObjectName" , "java.lang.ClassLoader" } );
- }
- catch (Exception e)
- {
- log.warn("Could not restore ejb timers", e);
- }
- }
-
- /**
- * The EJBDeployer calls this method. The EJBDeployer has set
- * all the plugins and interceptors that this bean requires and now proceeds
- * to initialize the chain. The method looks for the standard classes in
- * the URL, sets up the naming environment of the bean. The concrete
- * container classes should override this method to introduce
- * implementation specific initialization behaviour.
- *
- * @throws Exception if loading the bean class failed
- * (ClassNotFoundException) or setting up "java:"
- * naming environment failed (DeploymentException)
- */
- protected void createService() throws Exception
- {
- // Acquire classes from CL
- beanClass = classLoader.loadClass(metaData.getEjbClass());
-
- if (metaData.getLocalHome() != null)
- localHomeInterface = classLoader.loadClass(metaData.getLocalHome());
- if (metaData.getLocal() != null)
- localInterface = classLoader.loadClass(metaData.getLocal());
-
- localProxyFactory.setContainer(this);
- localProxyFactory.create();
- if (localHomeInterface != null)
- ejbModule.addLocalHome(this, localProxyFactory.getEJBLocalHome());
- ejbModule.createMissingPermissions(this, metaData);
- // Allow the policy to incorporate the policy configs
- Policy.getPolicy().refresh();
- }
-
- /**
- * A default implementation of starting the container service.
- * The container registers it's dynamic MBean interface in the JMX base.
- *
- * The concrete container classes should override this method to introduce
- * implementation specific start behaviour.
- *
- * todo implement the service lifecycle methods in an xmbean interceptor so
- * non lifecycle managed ops are blocked when mbean is not started.
- *
- * @throws Exception An exception that occured during start
- */
- protected void startService() throws Exception
- {
- // Setup "java:comp/env" namespace
- setupEnvironment();
-
- localProxyFactory.start();
- }
-
- /**
- * A default implementation of stopping the container service (no-op). The
- * concrete container classes should override this method to introduce
- * implementation specific stop behaviour.
- */
- protected void stopService() throws Exception
- {
- localProxyFactory.stop();
- removeTimerService(null);
- teardownEnvironment();
- }
-
- /**
- * A default implementation of destroying the container service (no-op).
- * The concrete container classes should override this method to introduce
- * implementation specific destroy behaviour.
- */
- protected void destroyService() throws Exception
- {
- localProxyFactory.destroy();
- ejbModule.removeLocalHome(this);
-
- beanClass = null;
- homeInterface = null;
- remoteInterface = null;
- localHomeInterface = null;
- localInterface = null;
- methodPermissionsCache.clear();
- // InvocationStatistics holds refs to Methods from
- // application classes, so to avoid a classloader
- // leak, lets not just resetStats() but also replace
- // the object
- invokeStats.resetStats(); // in case someone else has a ref
- invokeStats = new InvocationStatistics();
- marshalledInvocationMapping.clear();
- }
-
- /**
- * This method is called when a method call comes
- * in on the Home object. The Container forwards this call to the
- * interceptor chain for further processing.
- *
- * @param mi the object holding all info about this invocation
- * @return the result of the home invocation
- *
- * @throws Exception
- */
- public abstract Object internalInvokeHome(Invocation mi)
- throws Exception;
-
- /**
- * This method is called when a method call comes
- * in on an EJBObject. The Container forwards this call to the interceptor
- * chain for further processing.
- */
- public abstract Object internalInvoke(Invocation mi)
- throws Exception;
-
- abstract Interceptor createContainerInterceptor();
-
- public abstract void addInterceptor(Interceptor in);
-
- /** The detached invoker operation.
- *
- * @jmx.managed-operation
- *
- * @param mi - the method invocation context
- * @return the value of the ejb invocation
- * @throws Exception on error
- */
- public Object invoke(Invocation mi)
- throws Exception
- {
- ClassLoader callerClassLoader = SecurityActions.getContextClassLoader();
- long start = System.currentTimeMillis();
- Method m = null;
-
- Object type = null;
- String contextID = getJaccContextID();
- try
- {
- // JBAS-3732 - Remove classloader.equals optimization
- SecurityActions.setContextClassLoader(this.classLoader);
-
- // Set the JACC context id
- mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID);
- contextID = SecurityActions.setContextID(contextID);
- // Set the standard JACC policy context handler data is not a SEI msg
- if (mi.getType() != InvocationType.SERVICE_ENDPOINT)
- {
- EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
- }
- else
- {
- SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE);
- SOAPMsgPolicyContextHandler.setMessage(msg);
- }
- // Set custom JACC policy handlers
- BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData());
-
- // Check against home, remote, localHome, local, getHome,
- // getRemote, getLocalHome, getLocal
- type = mi.getType();
-
- // stat gathering: concurrent calls
- this.invokeStats.callIn();
-
- if (type == InvocationType.REMOTE ||
- type == InvocationType.LOCAL ||
- // web service calls come in as "ordinary" application invocations
- type == InvocationType.SERVICE_ENDPOINT)
- {
- if (mi instanceof MarshalledInvocation)
- {
- ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
-
- if (log.isTraceEnabled())
- {
- log.trace("METHOD REMOTE INVOKE " +
- mi.getObjectName() + "||" +
- mi.getMethod().getName() + "||");
- }
- }
-
- m = mi.getMethod();
-
- Object obj = internalInvoke(mi);
- return obj;
- }
- else if (type == InvocationType.HOME ||
- type == InvocationType.LOCALHOME)
- {
- if (mi instanceof MarshalledInvocation)
- {
-
- ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
-
- if (log.isTraceEnabled())
- {
- log.trace("METHOD HOME INVOKE " +
- mi.getObjectName() + "||" +
- mi.getMethod().getName() + "||" +
- mi.getArguments().toString());
- }
- }
- m = mi.getMethod();
-
- Object obj = internalInvokeHome(mi);
- return obj;
- }
- else
- {
- throw new MBeanException(new IllegalArgumentException(
- "Unknown invocation type: " + type));
- }
- }
- /**
- * Having to catch this exception here in case can not
- * unmarshall arguments, values, etc. Then, convert to
- * UnmarshalException as defined by spec (JBAS-2999)
- */
- catch (JBossLazyUnmarshallingException e)
- {
- InvocationType calltype = mi.getType();
- boolean isLocal =
- calltype == InvocationType.LOCAL ||
- calltype == InvocationType.LOCALHOME;
-
- // handle unmarshalling exception which should only come if problem unmarshalling
- // invocation payload, arguments, or value on remote end.
- if (isLocal)
- {
- throw new EJBException("UnmarshalException", e);
- }
- else
- {
- throw new MarshalException("MarshalException", e);
- }
- }
- finally
- {
- if (m != null)
- {
- long end = System.currentTimeMillis();
- long elapsed = end - start;
- this.invokeStats.updateStats(m, elapsed);
- }
-
- // stat gathering: concurrent calls
- this.invokeStats.callOut();
-
- // Restore the incoming class loader
- SecurityActions.setContextClassLoader(callerClassLoader);
-
- // Restore the incoming context id
- contextID = SecurityActions.setContextID(contextID);
-
- if (mi.getType() == InvocationType.SERVICE_ENDPOINT)
- {
- // Remove msg from ThreadLocal to prevent leakage into the thread pool
- SOAPMsgPolicyContextHandler.setMessage(null);
- }
- else
- {
- // Remove args from ThreadLocal to prevent leakage into the thread pool
- EJBArgsPolicyContextHandler.setArgs(null);
- }
-
- // Remove metadata from ThreadLocal to prevent leakage into the thread pool
- BeanMetaDataPolicyContextHandler.setMetaData(null);
- }
- }
-
- // Private -------------------------------------------------------
-
- /**
- * This method sets up the naming environment of the bean.
- * We create the java:comp/env namespace with properties, EJB-References,
- * and DataSource ressources.
- */
- private void setupEnvironment() throws Exception
- {
- BeanMetaData beanMetaData = getBeanMetaData();
- // debug
- log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName());
- ClassLoader tcl = SecurityActions.getContextClassLoader();
- log.debug("TCL: " + tcl);
-
- ORB orb = null;
- HandleDelegate hd = null;
- try
- {
- orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
- hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate");
- }
- catch (Throwable t)
- {
- log.debug("Unable to retrieve orb" + t.toString());
- }
-
- // Since the BCL is already associated with this thread we can start
- // using the java: namespace directly
- Context ctx = (Context)new InitialContext().lookup("java:comp");
-
- // Bind the orb
- if (orb != null)
- {
- NonSerializableFactory.rebind(ctx, "ORB", orb);
- log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
-
- NonSerializableFactory.rebind(ctx, "HandleDelegate", hd);
- log.debug("Bound java:comp:/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
- }
-
- Context envCtx = ctx.createSubcontext("env");
-
- // Bind environment properties
- {
- Iterator i = beanMetaData.getEnvironmentEntries();
- while (i.hasNext())
- {
- EnvEntryMetaData entry = (EnvEntryMetaData)i.next();
-
- log.debug("Binding env-entry: " + entry.getName() + " of type: " +
- entry.getType() + " to value:" + entry.getValue());
-
- EnvEntryMetaData.bindEnvEntry(envCtx, entry);
- }
- }
-
- // Bind EJB references
- {
- Iterator i = beanMetaData.getEjbReferences();
- while (i.hasNext())
- {
- EjbRefMetaData ref = (EjbRefMetaData)i.next();
- log.debug("Binding an EJBReference " + ref.getName());
-
- if (ref.getLink() != null)
- {
- // Internal link
- String linkName = ref.getLink();
- String jndiName = EjbUtil.findEjbLink(server, di, linkName);
-
- log.debug("Binding " + ref.getName() +
- " to ejb-link: " + linkName + " -> " + jndiName);
-
- if (jndiName == null)
- {
- String msg = "Failed to resolve ejb-link: " + linkName
- + " make by ejb-name: " + ref.getName();
- throw new DeploymentException(msg);
- }
-
- Util.bind(envCtx,
- ref.getName(),
- new LinkRef(jndiName));
-
- }
- else
- {
- // Get the invoker specific ejb-ref mappings
- Iterator it = beanMetaData.getInvokerBindings();
- Reference reference = null;
- while (it.hasNext())
- {
- String invokerBinding = (String)it.next();
- // Check for an invoker level jndi-name
- String name = ref.getInvokerBinding(invokerBinding);
- // Check for an global jndi-name
- if (name == null)
- name = ref.getJndiName();
- if (name == null)
- {
- throw new DeploymentException
- ("ejb-ref " + ref.getName() +
- ", expected either ejb-link in ejb-jar.xml or " +
- "jndi-name in jboss.xml");
- }
-
- StringRefAddr addr = new StringRefAddr(invokerBinding, name);
- log.debug("adding " + invokerBinding + ":" + name +
- " to Reference");
-
- if (reference == null)
- {
- reference = new Reference("javax.naming.LinkRef",
- ENCThreadLocalKey.class.getName(),
- null);
- }
- reference.add(addr);
- }
-
- // If there were invoker bindings create bind the reference
- if (reference != null)
- {
- if (ref.getJndiName() != null)
- {
- // Add default for the bean level ejb-ref/jndi-name
- StringRefAddr addr =
- new StringRefAddr("default", ref.getJndiName());
- reference.add(addr);
- }
- if (reference.size() == 1 && reference.get("default") == null)
- {
- /* There is only one invoker binding and its not default so
- create a default binding to allow the link to have a value
- when accessed without an invoker active.
- */
- StringRefAddr addr = (StringRefAddr)reference.get(0);
- String target = (String)addr.getContent();
- StringRefAddr addr1 = new StringRefAddr("default", target);
- reference.add(addr1);
- }
- Util.bind(envCtx, ref.getName(), reference);
- }
- else
- {
- // Bind the bean level ejb-ref/jndi-name
- if (ref.getJndiName() == null)
- {
- throw new DeploymentException("ejb-ref " + ref.getName() +
- ", expected either ejb-link in ejb-jar.xml " +
- "or jndi-name in jboss.xml");
- }
- Util.bind(envCtx,
- ref.getName(),
- new LinkRef(ref.getJndiName()));
- }
- }
- }
- }
-
- // Bind Local EJB references
- {
- Iterator i = beanMetaData.getEjbLocalReferences();
- while (i.hasNext())
- {
- EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
- String refName = ref.getName();
- log.debug("Binding an EJBLocalReference " + ref.getName());
-
- if (ref.getLink() != null)
- {
- // Internal link
- log.debug("Binding " + refName + " to bean source: " + ref.getLink());
-
- String jndiName = EjbUtil.findLocalEjbLink(server, di,
- ref.getLink());
-
- Util.bind(envCtx,
- ref.getName(),
- new LinkRef(jndiName));
- }
- else
- {
- // Bind the bean level ejb-local-ref/local-jndi-name
- if (ref.getJndiName() == null)
- {
- throw new DeploymentException("ejb-local-ref " + ref.getName() +
- ", expected either ejb-link in ejb-jar.xml " +
- "or local-jndi-name in jboss.xml");
- }
- Util.bind(envCtx,
- ref.getName(),
- new LinkRef(ref.getJndiName()));
- }
- }
- }
-
- // Bind service references
- UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
- for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
- {
- String refName = sref.getServiceRefName();
- new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
- }
-
- // Bind resource references
- {
- Iterator i = beanMetaData.getResourceReferences();
-
- // let's play guess the cast game ;) New metadata should fix this.
- ApplicationMetaData application =
- beanMetaData.getApplicationMetaData();
-
- while (i.hasNext())
- {
- ResourceRefMetaData ref = (ResourceRefMetaData)i.next();
-
- String resourceName = ref.getResourceName();
- String finalName = application.getResourceByName(resourceName);
- String resType = ref.getType();
- // If there was no resource-manager specified then an immeadiate
- // jndi-name or res-url name should have been given
- if (finalName == null)
- finalName = ref.getJndiName();
-
- if (finalName == null && resType.equals("java.net.URL") == false)
- {
- // the application assembler did not provide a resource manager
- // if the type is javax.sql.Datasoure use the default one
-
- if (ref.getType().equals("javax.sql.DataSource"))
- {
- // Go through JNDI and look for DataSource - use the first one
- Context dsCtx = new InitialContext();
- try
- {
- // Check if it is available in JNDI
- dsCtx.lookup("java:/DefaultDS");
- finalName = "java:/DefaultDS";
- }
- catch (Exception e)
- {
- log.debug("failed to lookup DefaultDS; ignoring", e);
- }
- finally
- {
- dsCtx.close();
- }
- }
-
- // Default failed? Warn user and move on
- // POTENTIALLY DANGEROUS: should this be a critical error?
- if (finalName == null)
- {
- log.warn("No resource manager found for " +
- ref.getResourceName());
- continue;
- }
- }
-
- if (resType.equals("java.net.URL"))
- {
- // URL bindings
- if (ref.getResURL() != null)
- {
- // The URL string was given by the res-url
- log.debug("Binding URL: " + ref.getRefName() +
- " to JDNI ENC as: " + ref.getResURL());
- URL resURL = new URL(ref.getResURL());
- Util.bind(envCtx, ref.getRefName(), resURL);
- }
- else
- {
- log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
- Object bind = null;
- if (ref.getJndiName() != null)
- {
- // Was the url given as a jndi-name reference to link to it
- bind = new LinkRef(finalName);
- }
- else
- {
- // The url string was given via a resource-name mapping
- bind = new URL(finalName);
- }
- Util.bind(envCtx, ref.getRefName(), bind);
- }
- }
- else
- {
- // Resource Manager bindings, should validate the type...
- log.debug("Binding resource manager: " + ref.getRefName() +
- " to JDNI ENC as: " + finalName);
-
- Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
- }
- }
- }
-
- // Bind resource env references
- {
- Iterator i = beanMetaData.getResourceEnvReferences();
- while (i.hasNext())
- {
- ResourceEnvRefMetaData resRef =
- (ResourceEnvRefMetaData)i.next();
- String encName = resRef.getRefName();
- String jndiName = resRef.getJndiName();
- // Should validate the type...
- log.debug("Binding env resource: " + encName +
- " to JDNI ENC as: " + jndiName);
-
- Util.bind(envCtx, encName, new LinkRef(jndiName));
- }
- }
-
- // Bind message destination references
- {
- Iterator i = beanMetaData.getMessageDestinationReferences();
-
- while (i.hasNext())
- {
- MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();
-
- String refName = ref.getRefName();
- String jndiName = ref.getJNDIName();
- String link = ref.getLink();
- if (link != null)
- {
- if (jndiName == null)
- {
- MessageDestinationMetaData messageDestination = getMessageDestination(link);
- if (messageDestination == null)
- throw new DeploymentException("message-destination-ref '" + refName +
- "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml");
- else
- {
- String linkJNDIName = messageDestination.getJNDIName();
- if (linkJNDIName == null)
- log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml");
- else
- jndiName = linkJNDIName;
- }
- }
- else
- log.warn("message-destination-ref '" + refName +
- "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml");
- }
- else if (jndiName == null)
- throw new DeploymentException("message-destination-ref '" + refName +
- "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml");
- Util.bind(envCtx, refName, new LinkRef(jndiName));
- }
- }
-
- // Create a java:comp/env/security/security-domain link to the container
- // or application security-domain if one exists so that access to the
- // security manager can be made without knowing the global jndi name.
-
- String securityDomain =
- metaData.getContainerConfiguration().getSecurityDomain();
- if (securityDomain == null)
- securityDomain = metaData.getApplicationMetaData().getSecurityDomain();
- if (securityDomain != null)
- {
- log.debug("Binding securityDomain: " + securityDomain +
- " to JDNI ENC as: security/security-domain");
-
- Util.bind(envCtx,
- "security/security-domain",
- new LinkRef(securityDomain));
- Util.bind(envCtx,
- "security/subject",
- new LinkRef(securityDomain + "/subject"));
- }
-
- log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName());
- }
-
- public MessageDestinationMetaData getMessageDestination(String link)
- {
- return EjbUtil.findMessageDestination(server, di, link);
- }
-
- /**
- *The <code>teardownEnvironment</code> method unbinds everything from
- * the comp/env context. It would be better do destroy the env context
- * but destroyContext is not currently implemented..
- *
- * @exception Exception if an error occurs
- */
- private void teardownEnvironment() throws Exception
- {
- Context ctx = (Context)new InitialContext().lookup("java:comp");
- ctx.unbind("env");
- log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName());
- try
- {
- NonSerializableFactory.unbind("ORB");
- log.debug("Unbound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
-
- NonSerializableFactory.unbind("HandleDelegate");
- log.debug("Unbound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
- }
- catch (NamingException ignored)
- {
- }
- }
-
- /**
- * The base class for container interceptors.
- *
- * <p>
- * All container interceptors perform the same basic functionality
- * and only differ slightly.
- */
- protected abstract class AbstractContainerInterceptor
- implements Interceptor
- {
- protected final Logger log = Logger.getLogger(this.getClass());
-
- public void setContainer(Container con)
- {
- }
-
- public void setNext(Interceptor interceptor)
- {
- }
-
- public Interceptor getNext()
- {
- return null;
- }
-
- public void create()
- {
- }
-
- public void start()
- {
- }
-
- public void stop()
- {
- }
-
- public void destroy()
- {
- }
-
- protected void rethrow(Exception e)
- throws Exception
- {
- if (e instanceof IllegalAccessException)
- {
- // Throw this as a bean exception...(?)
- throw new EJBException(e);
- }
- else if (e instanceof InvocationTargetException)
- {
- Throwable t = ((InvocationTargetException)e).getTargetException();
-
- if (t instanceof EJBException)
- {
- throw (EJBException)t;
- }
- else if (t instanceof Exception)
- {
- throw (Exception)t;
- }
- else if (t instanceof Error)
- {
- throw (Error)t;
- }
- else
- {
- throw new NestedError("Unexpected Throwable", t);
- }
- }
-
- throw e;
- }
-
- // Monitorable implementation ------------------------------------
-
- public void sample(Object s)
- {
- // Just here to because Monitorable request it but will be removed soon
- }
-
- public Map retrieveStatistic()
- {
- return null;
- }
-
- public void resetStatistic()
- {
- }
- }
-
- /** Perform the MBeanServer.invoke op in a PrivilegedExceptionAction if
- * running with a security manager.
- */
- class MBeanServerAction implements PrivilegedExceptionAction
- {
- private ObjectName target;
- String method;
- Object[] args;
- String[] sig;
-
- MBeanServerAction()
- {
- }
-
- MBeanServerAction(ObjectName target, String method, Object[] args, String[] sig)
- {
- this.target = target;
- this.method = method;
- this.args = args;
- this.sig = sig;
- }
-
- public Object run() throws Exception
- {
- Object rtnValue = server.invoke(target, method, args, sig);
- return rtnValue;
- }
-
- Object invoke(ObjectName target, String method, Object[] args, String[] sig)
- throws Exception
- {
- SecurityManager sm = System.getSecurityManager();
- Object rtnValue = null;
- if (sm == null)
- {
- // Direct invocation on MBeanServer
- rtnValue = server.invoke(target, method, args, sig);
- }
- else
- {
- try
- {
- // Encapsulate the invocation in a PrivilegedExceptionAction
- MBeanServerAction action = new MBeanServerAction(target, method, args, sig);
- rtnValue = AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException e)
- {
- Exception ex = e.getException();
- throw ex;
- }
- }
- return rtnValue;
- }
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/BeanMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/BeanMetaData.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/BeanMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,1108 +0,0 @@
-/*
- * 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.metadata;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Set;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.invocation.InvocationType;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.security.AnybodyPrincipal;
-import org.jboss.security.NobodyPrincipal;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.w3c.dom.Element;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-
-
-/**
- * A common meta data class for the entity, message-driven and session beans.
- *
- * @author <a href="mailto:sebastien.alborini at m4x.org">Sebastien Alborini</a>
- * @author <a href="mailto:peter.antman at tim.se">Peter Antman</a>
- * @author <a href="mailto:docodan at mvcsoft.com">Daniel OConnor</a>
- * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
- * @author <a href="mailto:criege at riege.com">Christian Riege</a>
- * @author <a href="mailto:Thomas.Diesler at jboss.org">Thomas Diesler</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- *
- * @version $Revision$
- */
-public abstract class BeanMetaData
- extends MetaData
-{
- // Constants -----------------------------------------------------
-
- public static final char SESSION_TYPE = 'S';
- public static final char ENTITY_TYPE = 'E';
- public static final char MDB_TYPE = 'M';
- public static final String LOCAL_INVOKER_PROXY_BINDING = "LOCAL";
-
- // Attributes ----------------------------------------------------
- /** The metadata from the toplevel ejb-jar.xml/jboss.xml elements */
- private ApplicationMetaData application;
-
- // from ejb-jar.xml
- /** The ejb-name element specifies an enterprise bean's name. This name is
- assigned by the ejb-jar file producer to name the enterprise bean in
- the ejb-jar file's deployment descriptor. The name must be unique
- among the names of the enterprise beans in the same ejb-jar file.
- */
- private String ejbName;
- /** The home element contains the fully-qualified name of the enterprise
- bean's home interface. */
- private String homeClass;
- /** The remote element contains the fully-qualified name of the enterprise
- bean's remote interface. */
- private String remoteClass;
- /** The local-home element contains the fully-qualified name of the
- enterprise bean's local home interface. */
- private String localHomeClass;
- /** The local element contains the fully-qualified name of the enterprise
- bean's local interface */
- private String localClass;
- /** The service-endpoint element contains the fully-qualified
- * name of the bean�s service endpoint interface (SEI) */
- protected String serviceEndpointClass;
- /** The ejb-class element contains the fully-qualified name of the
- enterprise bean's class. */
- private String ejbClass;
- /** The type of bean: ENTITY_TYPE, SESSION_TYPE, MDB_TYPE */
- protected char beanType;
- /** Is this bean's transactions managed by the container? */
- protected boolean containerManagedTx = true;
-
- /** The The env-entry element(s) contains the declaration of an enterprise
- bean's environment entry */
- private ArrayList environmentEntries = new ArrayList();
- /** The The ejb-ref element(s) for the declaration of a reference to an
- enterprise bean's home */
- private HashMap ejbReferences = new HashMap();
- /** The ejb-local-ref element(s) info */
- private HashMap ejbLocalReferences = new HashMap();
- /** The HashMap<ServiceRefMetaData> service-ref element(s) info */
- private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
- /** The security-role-ref element(s) info */
- private ArrayList securityRoleReferences = new ArrayList();
- /** The security-idemtity element info */
- private SecurityIdentityMetaData securityIdentity = null;
- /** */
- private SecurityIdentityMetaData ejbTimeoutIdentity = null;
- /** The resource-ref element(s) info */
- private HashMap resourceReferences = new HashMap();
- /** The resource-env-ref element(s) info */
- private HashMap resourceEnvReferences = new HashMap();
- /** The message destination references */
- private HashMap messageDestinationReferences = new HashMap();
- /** The method attributes */
- private ArrayList methodAttributes = new ArrayList();
- private ConcurrentReaderHashMap cachedMethodAttributes = new ConcurrentReaderHashMap();
- /** The assembly-descriptor/method-permission element(s) info */
- private ArrayList permissionMethods = new ArrayList();
- /** The assembly-descriptor/container-transaction element(s) info */
- private ArrayList transactionMethods = new ArrayList();
- /** A cache mapping methods to transaction attributes. */
- private ConcurrentReaderHashMap methodTx = new ConcurrentReaderHashMap();
- /** The assembly-descriptor/exclude-list method(s) */
- private ArrayList excludedMethods = new ArrayList();
- /** The invoker names to JNDI name mapping */
- protected HashMap invokerBindings = null;
- /** The cluster-config element info */
- private ClusterConfigMetaData clusterConfig = null;
-
- /** The JNDI name under with the home interface should be bound */
- private String jndiName;
-
- /** The JNDI name under with the local home interface should be bound */
- private String localJndiName;
- /** The container configuration name */
- protected String configurationName;
- /** The container configuration metadata */
- private ConfigurationMetaData configuration;
- /** The custom security proxy class */
- private String securityProxy;
-
- /** Is the bean marked as clustered */
- protected boolean clustered = false;
- /** Should the bean use by value call semeantics */
- protected boolean callByValue = false;
- /** Any object names for services the bean depends on */
- private Collection depends = new LinkedList();
-
- /** Describes the security configuration information for the IOR. Optional element. Since 4.0. */
- private IorSecurityConfigMetaData iorSecurityConfig;
- /** The jboss port-component binding for a ejb webservice */
- protected EjbPortComponentMetaData portComponent;
- /** Whether to throw an exception on a rollback if there is no exception */
- private boolean exceptionRollback = false;
- /** Whether timer persistence is enabled */
- private boolean timerPersistence = true;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
- public BeanMetaData(ApplicationMetaData app, char beanType)
- {
- this.application = app;
- this.beanType = beanType;
- }
-
- public boolean isSession()
- {
- return beanType == SESSION_TYPE;
- }
-
- public boolean isMessageDriven()
- {
- return beanType == MDB_TYPE;
- }
-
- public boolean isEntity()
- {
- return beanType == ENTITY_TYPE;
- }
-
- public String getHome()
- {
- return homeClass;
- }
-
- public String getRemote()
- {
- return remoteClass;
- }
-
- public String getLocalHome()
- {
- return localHomeClass;
- }
-
- public String getLocal()
- {
- return localClass;
- }
-
- public String getServiceEndpoint()
- {
- return serviceEndpointClass;
- }
-
- public EjbPortComponentMetaData getPortComponent()
- {
- return portComponent;
- }
-
- public String getEjbClass()
- {
- return ejbClass;
- }
-
- public String getEjbName()
- {
- return ejbName;
- }
-
- public boolean isContainerManagedTx()
- {
- return containerManagedTx;
- }
-
- public boolean isBeanManagedTx()
- {
- return !containerManagedTx;
- }
-
- public Iterator getEjbReferences()
- {
- return ejbReferences.values().iterator();
- }
-
- public Iterator getEjbLocalReferences()
- {
- return ejbLocalReferences.values().iterator();
- }
-
- protected abstract void defaultInvokerBindings();
-
- public Iterator getInvokerBindings()
- {
- if (invokerBindings == null)
- {
- // See if there is a container default invoker name
- String[] defaultNames = configuration.getInvokers();
- if (defaultNames.length > 0)
- {
- invokerBindings = new HashMap();
- for (int count = 0; count < defaultNames.length; count++)
- {
- invokerBindings.put(defaultNames[count], getJndiName());
- }
- }
- else
- {
- // Use the hard-coded defaults
- defaultInvokerBindings();
- }
- }
-
- return invokerBindings.keySet().iterator();
- }
-
- public String getInvokerBinding(String invokerName)
- {
- if (invokerBindings == null)
- {
- defaultInvokerBindings();
- }
-
- return (String)invokerBindings.get(invokerName);
- }
-
- public EjbRefMetaData getEjbRefByName(String name)
- {
- return (EjbRefMetaData)ejbReferences.get(name);
- }
-
- public EjbLocalRefMetaData getEjbLocalRefByName(String name)
- {
- return (EjbLocalRefMetaData)ejbLocalReferences.get(name);
- }
-
- public Iterator getEnvironmentEntries()
- {
- return environmentEntries.iterator();
- }
-
- public Iterator getSecurityRoleReferences()
- {
- return securityRoleReferences.iterator();
- }
-
- public Iterator getResourceReferences()
- {
- return resourceReferences.values().iterator();
- }
-
- public Iterator getResourceEnvReferences()
- {
- return resourceEnvReferences.values().iterator();
- }
-
- public Iterator getMessageDestinationReferences()
- {
- return messageDestinationReferences.values().iterator();
- }
-
- /**
- * @return HashMap<ServiceRefMetaData>
- */
- public HashMap<String, ServiceRefMetaData> getServiceReferences()
- {
- return serviceReferences;
- }
-
- public String getJndiName()
- {
- // jndiName may be set in jboss.xml
- if (jndiName == null)
- {
- jndiName = ejbName;
- }
- return jndiName;
- }
-
- /**
- * Gets the JNDI name under with the local home interface should be bound.
- * The default is local/<ejbName>
- */
- public String getLocalJndiName()
- {
- if (localJndiName == null)
- {
- // Generate a unique name based on ejbName + identityHashCode
- localJndiName = "local/" + ejbName + '@' + System.identityHashCode(ejbName);
- }
- return localJndiName;
- }
-
- /**
- * Gets the container jndi name used in the object name
- */
- public String getContainerObjectNameJndiName()
- {
- return getHome() != null ? getJndiName() : getLocalJndiName();
- }
-
- public String getConfigurationName()
- {
- if (configurationName == null)
- {
- configurationName = getDefaultConfigurationName();
- }
- return configurationName;
- }
-
- public ConfigurationMetaData getContainerConfiguration()
- {
- if (configuration == null)
- {
- String configName = getConfigurationName();
- configuration = application.getConfigurationMetaDataByName(configName);
- if (configuration == null)
- throw new IllegalStateException("Container config not found " + configName);
- }
- return configuration;
- }
-
- public String getSecurityProxy()
- {
- return securityProxy;
- }
-
- public SecurityIdentityMetaData getSecurityIdentityMetaData()
- {
- return securityIdentity;
- }
- public SecurityIdentityMetaData getEjbTimeoutIdentity()
- {
- return ejbTimeoutIdentity;
- }
-
- public ApplicationMetaData getApplicationMetaData()
- {
- return application;
- }
-
- public abstract String getDefaultConfigurationName();
-
- public Iterator getTransactionMethods()
- {
- return transactionMethods.iterator();
- }
-
- public Iterator getPermissionMethods()
- {
- return permissionMethods.iterator();
- }
-
- public Iterator getExcludedMethods()
- {
- return excludedMethods.iterator();
- }
-
- public void addTransactionMethod(MethodMetaData method)
- {
- transactionMethods.add(method);
- }
-
- public void addPermissionMethod(MethodMetaData method)
- {
- // Insert unchecked methods into the front of the list to speed
- // up their validation
- if (method.isUnchecked())
- {
- permissionMethods.add(0, method);
- }
- else
- {
- permissionMethods.add(method);
- }
- }
-
- public void addExcludedMethod(MethodMetaData method)
- {
- excludedMethods.add(method);
- }
-
- public byte getMethodTransactionType(String methodName, Class[] params, InvocationType iface)
- {
- // default value
- byte result = TX_UNKNOWN;
-
- MethodMetaData bestMatch = null;
- Iterator iterator = getTransactionMethods();
- while (iterator.hasNext())
- {
- MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, iface))
- {
-
- // this is the first match
- if (bestMatch == null)
- {
- bestMatch = m;
- }
- else
- {
- // this is a better match because the name is more precise
- if (bestMatch.getMethodName().equals("*"))
- {
- bestMatch = m;
- }
- // this is a better match because now we have parameters, we cant get any better
- if (m.getMethodParams().length > 0)
- {
- bestMatch = m;
- break;
- }
- }
- }
- }
-
- if (bestMatch != null)
- {
- result = bestMatch.getTransactionType();
- }
-
- return result;
- }
-
- // This should be cached, since this method is called very often
- public byte getTransactionMethod(Method m, InvocationType iface)
- {
- if (m == null)
- return MetaData.TX_SUPPORTS;
-
- Byte b = (Byte)methodTx.get(m);
- if (b != null) return b.byteValue();
-
- byte result = getMethodTransactionType(m.getName(), m.getParameterTypes(), iface);
-
- // provide default if method is not found in descriptor
- if (result == MetaData.TX_UNKNOWN)
- result = MetaData.TX_REQUIRED;
-
- methodTx.put(m, new Byte(result));
- return result;
- }
-
- public Collection getDepends()
- {
- Collection allDepends = new LinkedList(depends);
- allDepends.addAll(getContainerConfiguration().getDepends());
- return allDepends;
- }
-
- /**
- * Checks meta data to obtain the Method Attributes of a bean's method:
- * method attributes are read-only, idempotent and potentially other
- * ones as well.
- * These jboss-specific method attributes are described in jboss.xml
- */
- private MethodAttributes methodAttributesForMethod(String methodName)
- {
- if (methodName == null)
- methodName = "*null*";
-
- MethodAttributes ma =
- (MethodAttributes)cachedMethodAttributes.get(methodName);
-
- if (ma == null)
- {
- Iterator iterator = methodAttributes.iterator();
- while (iterator.hasNext() && ma == null)
- {
- ma = (MethodAttributes)iterator.next();
- if (!ma.patternMatches(methodName))
- {
- ma = null;
- }
- }
- if (ma == null)
- {
- ma = MethodAttributes.kDefaultMethodAttributes;
- }
-
- cachedMethodAttributes.put(methodName, ma);
- }
- return ma;
- }
-
- /**
- * Is this method a read-only method described in jboss.xml?
- */
- public boolean isMethodReadOnly(String methodName)
- {
- return methodAttributesForMethod(methodName).readOnly;
- }
-
- public boolean isMethodReadOnly(Method method)
- {
- if (method == null)
- {
- return false;
- }
- return methodAttributesForMethod(method.getName()).readOnly;
- }
-
- /**
- * Get the transaction timeout for the method
- */
- public int getTransactionTimeout(String methodName)
- {
- return methodAttributesForMethod(methodName).txTimeout;
- }
-
- public int getTransactionTimeout(Method method)
- {
- if (method == null)
- return 0;
- return getTransactionTimeout(method.getName());
- }
-
- /**
- * A somewhat tedious method that builds a Set<Principal> of the roles
- * that have been assigned permission to execute the indicated method. The
- * work performed is tedious because of the wildcard style of declaring
- * method permission allowed in the ejb-jar.xml descriptor. This method is
- * called by the Container.getMethodPermissions() when it fails to find the
- * prebuilt set of method roles in its cache.
- *
- * @return The Set<Principal> for the application domain roles that
- * caller principal's are to be validated against.
- */
- public Set getMethodPermissions(String methodName, Class[] params,
- InvocationType iface)
- {
- Set result = new HashSet();
- // First check the excluded method list as this takes priority over
- // all other assignments
- Iterator iterator = getExcludedMethods();
- while (iterator.hasNext())
- {
- MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, iface))
- {
- /* No one is allowed to execute this method so add a role that
- fails to equate to any Principal or Principal name and return.
- We don't return null to differentiate between an explicit
- assignment of no access and no assignment information.
- */
- result.add(NobodyPrincipal.NOBODY_PRINCIPAL);
- return result;
- }
- }
-
- // Check the permissioned methods list
- iterator = getPermissionMethods();
- while (iterator.hasNext())
- {
- MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, iface))
- {
- /* If this is an unchecked method anyone can access it so
- set the result set to a role that equates to any Principal or
- Principal name and return.
- */
- if (m.isUnchecked())
- {
- result.clear();
- result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
- break;
- }
- // Else, add all roles
- else
- {
- Iterator rolesIterator = m.getRoles().iterator();
- while (rolesIterator.hasNext())
- {
- String roleName = (String)rolesIterator.next();
- result.add(new SimplePrincipal(roleName));
- }
- }
- }
- }
-
- if (this.isExcludeMissingMethods() == false)
- {
- // If no permissions were assigned to the method, anybody can access it
- if (result.isEmpty())
- {
- result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
- }
- }
-
- return result;
- }
-
- /** Check to see if there was a method-permission or exclude-list statement
- * for the given method.
- *
- * @param methodName - the method name
- * @param params - the method parameter signature
- * @param iface - the method interface type
- * @return true if a matching method permission exists, false if no match
- */
- public boolean hasMethodPermission(String methodName, Class[] params,
- InvocationType iface)
- {
- // First check the excluded method list as this takes priority
- Iterator iterator = getExcludedMethods();
- while (iterator.hasNext())
- {
- MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, iface))
- {
- return true;
- }
- }
-
- // Check the permissioned methods list
- iterator = getPermissionMethods();
- while (iterator.hasNext())
- {
- MethodMetaData m = (MethodMetaData)iterator.next();
- if (m.patternMatches(methodName, params, iface))
- {
- return true;
- }
- }
-
- return false;
- }
-
- // Cluster configuration methods
- public boolean isClustered()
- {
- return this.clustered;
- }
-
- public boolean isCallByValue()
- {
- return callByValue;
- }
-
- public boolean isExcludeMissingMethods()
- {
- return application.isExcludeMissingMethods();
- }
-
- public ClusterConfigMetaData getClusterConfigMetaData()
- {
- if (clusterConfig == null)
- {
- clusterConfig = getContainerConfiguration().getClusterConfigMetaData();
- if (clusterConfig == null)
- {
- clusterConfig = new ClusterConfigMetaData();
- }
- /* All beans associated with a container are the same type
- so this can be done more than once without harm */
- clusterConfig.init(this);
- }
- return this.clusterConfig;
- }
-
- public IorSecurityConfigMetaData getIorSecurityConfigMetaData()
- {
- return iorSecurityConfig;
- }
-
- public boolean getExceptionRollback()
- {
- return exceptionRollback;
- }
-
- public boolean getTimerPersistence()
- {
- return timerPersistence;
- }
-
- /** Called to parse the ejb-jar.xml enterprise-beans child ejb elements
- * @param element one of session/entity/message-driven
- * @throws DeploymentException
- */
- public void importEjbJarXml(Element element)
- throws DeploymentException
- {
- // set the ejb-name
- ejbName = getElementContent(getUniqueChild(element, "ejb-name"));
-
- // Set the interfaces classes for all types but MessageDriven
- if (isMessageDriven() == false)
- {
- homeClass = getElementContent(getOptionalChild(element, "home"));
- remoteClass = getElementContent(getOptionalChild(element, "remote"));
- localHomeClass = getElementContent(getOptionalChild(element,
- "local-home"));
- localClass = getElementContent(getOptionalChild(element, "local"));
- }
- ejbClass = getElementContent(getUniqueChild(element, "ejb-class"));
-
- // set the environment entries
- Iterator iterator = getChildrenByTagName(element, "env-entry");
-
- while (iterator.hasNext())
- {
- Element envEntry = (Element)iterator.next();
-
- EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
- envEntryMetaData.importEjbJarXml(envEntry);
-
- environmentEntries.add(envEntryMetaData);
- }
-
- // set the ejb references
- iterator = getChildrenByTagName(element, "ejb-ref");
-
- while (iterator.hasNext())
- {
- Element ejbRef = (Element)iterator.next();
-
- EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
- ejbRefMetaData.importEjbJarXml(ejbRef);
-
- ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
- }
-
- // set the ejb local references
- iterator = getChildrenByTagName(element, "ejb-local-ref");
-
- while (iterator.hasNext())
- {
- Element ejbLocalRef = (Element)iterator.next();
-
- EjbLocalRefMetaData ejbLocalRefMetaData = new EjbLocalRefMetaData();
- ejbLocalRefMetaData.importEjbJarXml(ejbLocalRef);
-
- ejbLocalReferences.put(ejbLocalRefMetaData.getName(),
- ejbLocalRefMetaData);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(element, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element)iterator.next();
- new ServiceRefDelegate().newServiceRefMetaData();
- ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
- refMetaData.importStandardXml(serviceRef);
- serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
- }
-
- // set the security roles references
- iterator = getChildrenByTagName(element, "security-role-ref");
-
- while (iterator.hasNext())
- {
- Element secRoleRef = (Element)iterator.next();
- SecurityRoleRefMetaData securityRoleRefMetaData = new SecurityRoleRefMetaData();
- securityRoleRefMetaData.importEjbJarXml(secRoleRef);
- securityRoleReferences.add(securityRoleRefMetaData);
- }
-
- // The security-identity element
- Element securityIdentityElement = getOptionalChild(element,
- "security-identity");
- if (securityIdentityElement != null)
- {
- securityIdentity = new SecurityIdentityMetaData();
- securityIdentity.importEjbJarXml(securityIdentityElement);
- }
-
- // set the resource references
- iterator = getChildrenByTagName(element, "resource-ref");
-
- while (iterator.hasNext())
- {
- Element resourceRef = (Element)iterator.next();
-
- ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
- resourceRefMetaData.importEjbJarXml(resourceRef);
-
- resourceReferences.put(resourceRefMetaData.getRefName(),
- resourceRefMetaData);
- }
-
- // Parse the resource-env-ref elements
- iterator = getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element)iterator.next();
- ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
- refMetaData.importEjbJarXml(resourceRef);
- resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
- }
-
- // set the message destination references
- iterator = getChildrenByTagName(element, "message-destination-ref");
- while (iterator.hasNext())
- {
- Element messageDestinationRef = (Element)iterator.next();
-
- MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
- messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
-
- messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
- }
- }
-
- /** Called to parse the jboss.xml enterprise-beans child ejb elements
- * @param element one of session/entity/message-driven
- * @throws DeploymentException
- */
- public void importJbossXml(Element element) throws DeploymentException
- {
- // we must not set defaults here, this might never be called
-
- // set the jndi name, (optional)
- jndiName = getElementContent(getOptionalChild(element, "jndi-name"));
-
- // set the JNDI name under with the local home interface should be
- // bound (optional)
- localJndiName = getElementContent(getOptionalChild(element, "local-jndi-name"));
-
- // Determine if the bean should use by value call semantics
- String callByValueElt = getElementContent(getOptionalChild(element, "call-by-value"), (callByValue ? "True" : "False"));
- callByValue = callByValueElt.equalsIgnoreCase("True");
-
- // set the configuration (optional)
- configurationName = getElementContent(getOptionalChild(element, "configuration-name"));
- if (configurationName != null && getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null)
- {
- throw new DeploymentException("configuration '" + configurationName + "' not found in standardjboss.xml or jboss.xml");
- }
-
- // Get the security proxy
- securityProxy = getElementContent(getOptionalChild(element, "security-proxy"), securityProxy);
-
- // Throw an exception when marked rollback with no exception thrown
- exceptionRollback = MetaData.getOptionalChildBooleanContent(element, "exception-on-rollback", false);
-
- // Whether to persist ejb timers across redeployments
- timerPersistence = MetaData.getOptionalChildBooleanContent(element, "timer-persistence", true);
-
- // update the resource references (optional)
- Iterator iterator = getChildrenByTagName(element, "resource-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element)iterator.next();
- String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
- ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)resourceReferences.get(resRefName);
-
- if (resourceRefMetaData == null)
- {
- throw new DeploymentException("resource-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- resourceRefMetaData.importJbossXml(resourceRef);
- }
-
- // Set the resource-env-ref deployed jndi names
- iterator = getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element)iterator.next();
- String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
- ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)resourceEnvReferences.get(resRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("resource-env-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- refMetaData.importJbossXml(resourceRef);
- }
-
- // update the message destination references (optional)
- iterator = getChildrenByTagName(element, "message-destination-ref");
- while (iterator.hasNext())
- {
- Element messageDestinationRef = (Element)iterator.next();
- String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name"));
- MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData)messageDestinationReferences.get(messageDestinationRefName);
- if (messageDestinationRefMetaData == null)
- throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss.xml but not in ejb-jar.xml");
- messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
- }
-
- // set the external ejb-references (optional)
- iterator = getChildrenByTagName(element, "ejb-ref");
- while (iterator.hasNext())
- {
- Element ejbRef = (Element)iterator.next();
- String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
- if (ejbRefMetaData == null)
- {
- throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- ejbRefMetaData.importJbossXml(ejbRef);
- }
-
-
- //handle the ejb-local-ref elements
- iterator = getChildrenByTagName(element, "ejb-local-ref");
- while (iterator.hasNext())
- {
- Element ejbLocalRef = (Element)iterator.next();
- String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
-
- EjbLocalRefMetaData ejbLocalRefMetaData = getEjbLocalRefByName(ejbLocalRefName);
- if (ejbLocalRefMetaData == null)
- {
- throw new DeploymentException("ejb-local-ref " + ejbLocalRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(element, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element)iterator.next();
- String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
- ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("service-ref " + serviceRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- refMetaData.importJBossXml(serviceRef);
- }
-
- // Get the security identity
- Element securityIdentityElement = getOptionalChild(element, "security-identity");
- if (securityIdentityElement != null)
- {
- if (securityIdentity == null)
- throw new DeploymentException(ejbName + ", security-identity in jboss.xml has no match in ejb-jar.xml");
- String runAsPrincipal = getElementContent(getUniqueChild(securityIdentityElement,
- "run-as-principal"), securityIdentity.getRunAsPrincipalName());
- securityIdentity.setRunAsPrincipalName(runAsPrincipal);
- }
-
- // Get the ejbTimeout caller identity
- Element ejbTimeoutIdentityElement = getOptionalChild(element, "ejb-timeout-identity");
- if (ejbTimeoutIdentityElement != null)
- {
- ejbTimeoutIdentity = new SecurityIdentityMetaData();
- String runAsPrincipal = getElementContent(getUniqueChild(ejbTimeoutIdentityElement,
- "run-as-principal"), null);
- ejbTimeoutIdentity.setRunAsRoleName("ejbTimeout");
- if( runAsPrincipal != null && runAsPrincipal.length() > 0 )
- ejbTimeoutIdentity.setRunAsPrincipalName(runAsPrincipal);
- else
- ejbTimeoutIdentity.setUseCallerIdentity(true);
- }
-
- // Method attributes of the bean
- Element mas = getOptionalChild(element, "method-attributes");
- if (mas != null)
- {
- // read in the read-only methods
- iterator = getChildrenByTagName(mas, "method");
- while (iterator.hasNext())
- {
- MethodAttributes ma = new MethodAttributes();
- Element maNode = (Element)iterator.next();
- ma.pattern = getElementContent(getUniqueChild(maNode, "method-name"));
- ma.readOnly = getOptionalChildBooleanContent(maNode, "read-only");
- ma.idempotent = getOptionalChildBooleanContent(maNode, "idempotent");
- String txTimeout = getOptionalChildContent(maNode, "transaction-timeout");
- try
- {
- if (txTimeout != null && txTimeout.length() > 0)
- ma.txTimeout = Integer.parseInt(txTimeout);
- }
- catch (Exception ignore)
- {
- log.debug("Ignoring transaction-timeout '" + txTimeout + "'", ignore);
- }
- methodAttributes.add(ma);
- }
- }
-
- // Invokers
- // If no invoker bindings have been defined they will be defined
- // in EntityMetaData, or SessionMetaData
- Element inv = getOptionalChild(element, "invoker-bindings");
- if (inv != null)
- {
- // read in the read-only methods
- iterator = getChildrenByTagName(inv, "invoker");
- invokerBindings = new HashMap();
- while (iterator.hasNext())
- {
- Element node = (Element)iterator.next();
- String invokerBindingName = getUniqueChildContent(node, "invoker-proxy-binding-name");
- String jndiBinding = getOptionalChildContent(node, "jndi-name");
-
- if (jndiBinding == null)
- {
- jndiBinding = getJndiName(); // default to jndiName
- }
- invokerBindings.put(invokerBindingName, jndiBinding);
-
- // set the external ejb-references (optional)
- Iterator ejbrefiterator = getChildrenByTagName(node, "ejb-ref");
- while (ejbrefiterator.hasNext())
- {
- Element ejbRef = (Element)ejbrefiterator.next();
- String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
- if (ejbRefMetaData == null)
- {
- throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
- }
- ejbRefMetaData.importJbossXml(invokerBindingName, ejbRef);
- }
- }
- }
-
- // Determine if the bean is to be deployed in the cluster (more
- // advanced config will be added in the future)
- String clusteredElt = getElementContent(getOptionalChild(element, "clustered"), (clustered ? "True" : "False"));
- clustered = clusteredElt.equalsIgnoreCase("True");
-
- Element clusterConfigElement = getOptionalChild(element, "cluster-config");
- if (clusterConfigElement != null)
- {
- this.clusterConfig = new ClusterConfigMetaData();
- clusterConfig.init(this);
- clusterConfig.importJbossXml(clusterConfigElement);
- }
-
- //Get depends object names
- for (Iterator dependsElements = getChildrenByTagName(element, "depends"); dependsElements.hasNext();)
- {
- Element dependsElement = (Element)dependsElements.next();
- String dependsName = getElementContent(dependsElement);
- depends.add(ObjectNameFactory.create(dependsName));
- } // end of for ()
-
- // ior-security-config optional element
- Element iorSecurityConfigEl = getOptionalChild(element, "ior-security-config");
- if (iorSecurityConfigEl != null)
- {
- iorSecurityConfig = new IorSecurityConfigMetaData(iorSecurityConfigEl);
- }
-
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/ClientMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/ClientMetaData.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/ClientMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,326 +0,0 @@
-/*
- * 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.metadata;
-
-// $Id$
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.w3c.dom.Element;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.net.URLClassLoader;
-
-/** The metdata data from a j2ee application-client.xml descriptor
- *
- * @author Scott.Stark at jboss.org
- * @author Thomas.Diesler at jboss.org
- * @version $Revision$
- */
-public class ClientMetaData
-{
- /** The application-client/display-name */
- private String displayName;
- /** The location for the server side client context ENC bindings */
- private String jndiName;
- /** An ArrayList<EnvEntryMetaData> for the env-entry element(s) */
- private ArrayList environmentEntries = new ArrayList();
- /** A HashMap<String, EjbRefMetaData> for the ejb-ref element(s) */
- private HashMap ejbReferences = new HashMap();
- /** The HashMap<String, ServiceRefMetaData> service-ref element(s) info */
- private HashMap<String,ServiceRefMetaData> serviceReferences = new HashMap<String,ServiceRefMetaData>();
- /** A HashMap<String, ResourceRefMetaData> resource-ref element(s) info */
- private HashMap resourceReferences = new HashMap();
- /** A HashMap<String, ResourceEnvRefMetaData> resource-env-ref element(s) info */
- private HashMap resourceEnvReferences = new HashMap();
- /** A HashMap<String, ArrayList<ResourceEnvRefMetaData>> of
- * message-destination-ref that resolve to a jndi-name via a message-destination
- * via a message-destination-link
- */
- private HashMap resourceEnvReferenceLinks = new HashMap();
- /** The JAAS callback handler */
- private String callbackHandler;
-
- /** The ClassLoader to load additional resources */
- private URLClassLoader resourceCl;
-
- /** Set the ClassLoader to load additional resources */
- public void setResourceClassLoader(URLClassLoader resourceCl)
- {
- this.resourceCl = resourceCl;
- }
-
- /** The application-client/display-name
- * @return application-client/display-name value
- */
- public String getDisplayName()
- {
- return displayName;
- }
-
- /** The location for the server side client context ENC bindings
- * @return the JNDI name for the server side client context ENC bindings. This
- * is either the jboss-client/jndi-name or the application-client/display-name
- * value.
- */
- public String getJndiName()
- {
- String name = jndiName;
- if( name == null )
- name = displayName;
- return name;
- }
-
- /**
- * @return ArrayList<EnvEntryMetaData>
- */
- public ArrayList getEnvironmentEntries()
- {
- return environmentEntries;
- }
- /**
- * @return HashMap<EjbRefMetaData>
- */
- public HashMap getEjbReferences()
- {
- return ejbReferences;
- }
- /**
- * @return HashMap<ResourceRefMetaData>
- */
- public HashMap getResourceReferences()
- {
- return resourceReferences;
- }
- /**
- * @return HashMap<ResourceEnvRefMetaData>
- */
- public HashMap getResourceEnvReferences()
- {
- return resourceEnvReferences;
- }
- /**
- * @return The CallbackHandler if defined, null otherwise
- */
- public String getCallbackHandler()
- {
- return callbackHandler;
- }
- /**
- * @return HashMap<ServiceRefMetaData>
- */
- public HashMap<String,ServiceRefMetaData> getServiceReferences()
- {
- return serviceReferences;
- }
-
- public void importClientXml(Element element)
- throws DeploymentException
- {
- displayName = MetaData.getOptionalChildContent(element, "display-name");
-
- // set the environment entries
- Iterator iterator = MetaData.getChildrenByTagName(element, "env-entry");
-
- while (iterator.hasNext())
- {
- Element envEntry = (Element) iterator.next();
-
- EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
- envEntryMetaData.importEjbJarXml(envEntry);
-
- environmentEntries.add(envEntryMetaData);
- }
-
- // set the ejb references
- iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
-
- while (iterator.hasNext())
- {
- Element ejbRef = (Element) iterator.next();
-
- EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
- ejbRefMetaData.importEjbJarXml(ejbRef);
-
- ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(element, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element) iterator.next();
- ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
- refMetaData.importStandardXml(serviceRef);
- serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
- }
-
- // The callback-handler element
- Element callbackElement = MetaData.getOptionalChild(element,
- "callback-handler");
- if (callbackElement != null)
- {
- callbackHandler = MetaData.getElementContent(callbackElement);
- }
-
- // set the resource references
- iterator = MetaData.getChildrenByTagName(element, "resource-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
-
- ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
- resourceRefMetaData.importEjbJarXml(resourceRef);
-
- resourceReferences.put(resourceRefMetaData.getRefName(),
- resourceRefMetaData);
- }
-
- // Parse the resource-env-ref elements
- iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
- refMetaData.importEjbJarXml(resourceRef);
- resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
- }
-
- // Parse the message-destination-ref elements
- iterator = MetaData.getChildrenByTagName(element, "message-destination-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
- refMetaData.importEjbJarXml(resourceRef);
- /* A message-destination-ref is linked to a jndi-name either via
- the message-destination-ref/message-destination-ref-name mapping to
- a jboss resource-env-ref/resource-env-ref-name if there is no
- message-destination-link, or by the message-destination-link ->
- message-destination/message-destination-name mapping to a jboss
- resource-env-ref/resource-env-ref-name.
- */
- String refName = refMetaData.getRefName();
- String link = refMetaData.getLink();
- if( link != null )
- {
- ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(link);
- if( linkedRefs == null )
- {
- linkedRefs = new ArrayList();
- resourceEnvReferenceLinks.put(link, linkedRefs);
- }
- linkedRefs.add(refMetaData);
- }
- resourceEnvReferences.put(refName, refMetaData);
- }
- }
-
- public void importJbossClientXml(Element element) throws DeploymentException
- {
- jndiName = MetaData.getOptionalChildContent(element, "jndi-name");
-
- // Get the JNDI names of ejb-refs
- Iterator iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
- while (iterator.hasNext())
- {
- Element ejbRef = (Element) iterator.next();
- String ejbRefName = MetaData.getElementContent(
- MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
- if (ejbRefMetaData == null)
- {
- throw new DeploymentException("ejb-ref " + ejbRefName
- + " found in jboss-client.xml but not in application-client.xml");
- }
- ejbRefMetaData.importJbossXml(ejbRef);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(element, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element) iterator.next();
- String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
- ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("service-ref " + serviceRefName
- + " found in jboss-client.xml but not in application-client.xml");
- }
- refMetaData.importJBossXml(serviceRef);
- }
-
- // Get the JNDI name binding for resource-refs
- iterator = MetaData.getChildrenByTagName(element, "resource-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- String resRefName = MetaData.getElementContent(
- MetaData.getUniqueChild(resourceRef, "res-ref-name"));
- ResourceRefMetaData resourceRefMetaData =
- (ResourceRefMetaData) resourceReferences.get(resRefName);
- if (resourceRefMetaData == null)
- {
- throw new DeploymentException("resource-ref " + resRefName
- + " found in jboss-client.xml but not in application-client.xml");
- }
- resourceRefMetaData.importJbossXml(resourceRef);
- }
-
- // Get the JNDI name binding resource-env-refs
- iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- String resRefName = MetaData.getElementContent(
- MetaData.getUniqueChild(resourceRef, "resource-env-ref-name"));
- ResourceEnvRefMetaData refMetaData =
- (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
- if (refMetaData == null)
- {
- // Try the resourceEnvReferenceLinks
- ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(resRefName);
- if( linkedRefs != null )
- {
- for(int n = 0; n < linkedRefs.size(); n ++)
- {
- refMetaData = (ResourceEnvRefMetaData) linkedRefs.get(n);
- refMetaData.importJbossXml(resourceRef);
- }
- }
- else
- {
- throw new DeploymentException("resource-env-ref " + resRefName
- + " found in jboss-client.xml but not in application-client.xml");
- }
- }
- else
- {
- refMetaData.importJbossXml(resourceRef);
- }
- }
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/WebMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/WebMetaData.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/WebMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,1414 +0,0 @@
-/*
- * 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.metadata;
-
-// $Id$
-
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-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 org.jboss.deployment.DeploymentException;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.security.RunAsIdentity;
-import org.jboss.security.SecurityRoleMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.w3c.dom.Element;
-
-/** A representation of the web.xml and jboss-web.xml deployment
- * descriptors as used by the AbstractWebContainer web container integration
- * support class.
- *
- * @see XmlLoadable
- * @see org.jboss.web.AbstractWebContainer
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class WebMetaData extends MetaData
-{
- private static Logger log = Logger.getLogger(WebMetaData.class);
-
- /** The web.xml servlet <String, String> */
- private HashMap servletClassNames = new HashMap();
-
- /** The web.xml servlet-param <String,String> */
- private HashMap servletParams = new HashMap();
-
- /** The web.xml context-param <String,String> */
- private HashMap contextParams = new HashMap();
-
- /** The web.xml servlet-mapping <String, String> */
- private HashMap servletMappings = new HashMap();
-
- /** The web.xml resource-refs <String, String> */
- private HashMap resourceReferences = new HashMap();
-
- /** The web.xml resource-env-refs <String, String> */
- private HashMap resourceEnvReferences = new HashMap();
-
- /** The web.xml message-destination-refs <String, MessageDestinationRefMetaData> */
- private HashMap messageDestinationReferences = new HashMap();
-
- /** The web.xml message-destination <String, MessageDestinationMetaData> */
- private HashMap messageDestinations = new HashMap();
-
- /** web.xml env-entrys */
- private ArrayList environmentEntries = new ArrayList();
-
- /** web.xml security-constraint <WebSecurityMetaData> */
- private ArrayList securityContraints = new ArrayList();
-
- /** The HashMap<String, SecurityRoleMetaData> for the security-roles */
- private HashMap securityRoles = new HashMap();
-
- /** web.xml ejb-refs */
- private HashMap ejbReferences = new HashMap();
-
- /** web.xml ejb-local-refs */
- private HashMap ejbLocalReferences = new HashMap();
-
- /** The web.xml service-refs */
- private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
-
- /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
- private HashMap securityRoleReferences = new HashMap();
-
- /** The web.xml servlet/run-as <String servlet-name, String role> */
- private HashMap runAsNames = new HashMap();
-
- /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity> */
- private HashMap runAsIdentity = new HashMap();
-
- /** The web.xml distributable flag */
- private boolean distributable = false;
-
- /** The jboss-web.xml class-loading.java2ClassLoadingCompliance flag */
- private boolean java2ClassLoadingCompliance = false;
-
- /** The jboss-web.xml class-loading jboss class loader flag */
- private boolean useJBossWebLoader = false;
-
- /** The jboss-web.xml class-loading/loader-repository */
- private LoaderRepositoryConfig loaderConfig;
-
- /** The war context root as specified at the jboss-web.xml descriptor level. */
- private String contextRoot;
-
- /** The JACC context id for the container */
- private String jaccContextID;
-
- /** The jboss-web.xml server container virtual hosts the war should be deployed into */
- private ArrayList virtualHosts = new ArrayList();
-
- /** The jboss-web.xml JNDI name of the security domain implementation */
- private String securityDomain;
-
- /** JBAS-1824: Flag whether WebResourcePermission(url,null) needed for rolename '*' */
- private boolean jaccRoleNameStar = false;
-
- /** The jboss-web.xml securityDomain flushOnSessionInvalidation attribute */
- private boolean flushOnSessionInvalidation;
-
- /** A HashMap<String, String> for webservice description publish locations */
- private HashMap wsdlPublishLocationMap = new HashMap();
-
- /** True if this is a web service deployment */
- private boolean webServiceDeployment;
-
- /** The optional JBossWS config-name */
- private String configName;
-
- /** The optional JBossWS config-file */
- private String configFile;
-
- /** The web context class loader used to create the java:comp context */
- private ClassLoader encLoader;
-
- /** The web context class loader, used to create the ws4ee service endpoint */
- private ClassLoader cxtLoader;
-
- /** ArrayList<ObjectName> of the web app dependencies */
- private ArrayList depends = new ArrayList();
-
- public static final int SESSION_INVALIDATE_ACCESS = 0;
-
- public static final int SESSION_INVALIDATE_SET_AND_GET = 1;
-
- public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET = 2;
-
- public static final int SESSION_INVALIDATE_SET = 3;
-
- private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
-
- public static final int REPLICATION_TYPE_SYNC = 0;
-
- public static final int REPLICATION_TYPE_ASYNC = 1;
-
- /**
- * @deprecated Since JBoss3.2.6.
- */
- private int replicationType = REPLICATION_TYPE_SYNC;
-
- /** Specify the session replication granularity level: session --- whole session level,
- * attribute --- per attribute change, field --- fine grained user object level.
- *
- */
- public static final int REPLICATION_GRANULARITY_SESSION = 0;
-
- public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1;
-
- public static final int REPLICATION_GRANULARITY_FIELD = 2;
-
- private int replicationGranularity = REPLICATION_GRANULARITY_SESSION;
-
- /**
- * If the replication granularity is FIELD, specify whether to use batch mode
- * for pojo replication or not.
- */
- private boolean replicationFieldBatchMode = true;
-
- /** Should the context use session cookies or use default */
- private int sessionCookies = SESSION_COOKIES_DEFAULT;
-
- public static final int SESSION_COOKIES_DEFAULT = 0;
-
- public static final int SESSION_COOKIES_ENABLED = 1;
-
- public static final int SESSION_COOKIES_DISABLED = 2;
-
- /** The ClassLoader to load additional resources */
- private URLClassLoader resourceCl;
-
- /** Set the ClassLoader to load additional resources */
- public void setResourceClassLoader(URLClassLoader resourceCl)
- {
- this.resourceCl = resourceCl;
- }
-
- /** Return an iterator of the env-entry mappings.
- @return Iterator of EnvEntryMetaData objects.
- */
- public Iterator getEnvironmentEntries()
- {
- return environmentEntries.iterator();
- }
-
- /**
- *
- * @param environmentEntries - Collection<EnvEntryMetaData>
- */
- public void setEnvironmentEntries(Collection environmentEntries)
- {
- this.environmentEntries.clear();
- this.environmentEntries.addAll(environmentEntries);
- }
-
- /** Return an iterator of the ejb-ref mappings.
- @return Iterator of EjbRefMetaData objects.
- */
- public Iterator getEjbReferences()
- {
- return ejbReferences.values().iterator();
- }
-
- /**
- *
- * @param ejbReferences - Map<String, EjbRefMetaData>
- */
- public void setEjbReferences(Map ejbReferences)
- {
- this.ejbReferences.clear();
- this.ejbReferences.putAll(ejbReferences);
- }
-
- /** Return an iterator of the ejb-local-ref mappings.
- @return Iterator of EjbLocalRefMetaData objects.
- */
- public Iterator getEjbLocalReferences()
- {
- return ejbLocalReferences.values().iterator();
- }
-
- /**
- *
- * @param ejbReferences - Map<String, EjbRefMetaData>
- */
- public void setEjbLocalReferences(Map ejbReferences)
- {
- this.ejbLocalReferences.clear();
- this.ejbLocalReferences.putAll(ejbReferences);
- }
-
- /** Return an iterator of the resource-ref mappings.
- @return Iterator of ResourceRefMetaData objects.
- */
- public Iterator getResourceReferences()
- {
- return resourceReferences.values().iterator();
- }
-
- /**
- *
- * @param resourceReferences - Map<String, ResourceRefMetaData>
- */
- public void setResourceReferences(Map resourceReferences)
- {
- this.resourceReferences.clear();
- this.resourceReferences.putAll(resourceReferences);
- }
-
- /** Return an iterator of the resource-ref mappings.
- @return Iterator of ResourceEnvRefMetaData objects.
- */
- public Iterator getResourceEnvReferences()
- {
- return resourceEnvReferences.values().iterator();
- }
-
- /**
- *
- * @param resourceReferences - Map<String, ResourceEnvRefMetaData>
- */
- public void setResourceEnvReferences(Map resourceReferences)
- {
- this.resourceEnvReferences.clear();
- this.resourceEnvReferences.putAll(resourceReferences);
- }
-
- /**
- * Return an iterator of message-destination-refs.
- *
- * @return Iterator of MessageDestinationRefMetaData objects.
- */
- public Iterator getMessageDestinationReferences()
- {
- return messageDestinationReferences.values().iterator();
- }
-
- /**
- *
- * @param messageDestinationReferences - Map<String, MessageDestinationRefMetaData>
- */
- public void setMessageDestinationReferences(Map messageDestinationReferences)
- {
- this.messageDestinationReferences.clear();
- this.messageDestinationReferences.putAll(messageDestinationReferences);
- }
-
- /**
- * Get a message destination metadata
- *
- * @param name the name of the message destination
- * @return the message destination metadata
- */
- public MessageDestinationMetaData getMessageDestination(String name)
- {
- return (MessageDestinationMetaData) messageDestinations.get(name);
- }
-
- /**
- *
- * @param messageDestinations - Map<String, MessageDestinationMetaData>
- */
- public void setMessageDestination(Map messageDestinations)
- {
- this.messageDestinations.clear();
- this.messageDestinations.putAll(messageDestinations);
- }
-
- public Map<String, ServiceRefMetaData> getServiceReferences()
- {
- return serviceReferences;
- }
-
- public void setServiceReferences(Map<String, ServiceRefMetaData> serviceReferences)
- {
- this.serviceReferences.clear();
- this.serviceReferences.putAll(serviceReferences);
- }
-
- /** This the the jboss-web.xml descriptor context-root and it
- *is only meaningful if a war is deployed outside of an ear.
- */
- public String getContextRoot()
- {
- return contextRoot;
- }
-
- public void setContextRoot(String contextRoot)
- {
- this.contextRoot = contextRoot;
- }
-
- public String getConfigFile()
- {
- return configFile;
- }
-
- public void setConfigFile(String configFile)
- {
- this.configFile = configFile;
- }
-
- public String getConfigName()
- {
- return configName;
- }
-
- public void setConfigName(String configName)
- {
- this.configName = configName;
- }
-
- /** Get the optional wsdl publish location from jboss-web.xml. */
- public String getWsdlPublishLocationByName(String name)
- {
- return (String) wsdlPublishLocationMap.get(name);
- }
-
- /**
- *
- * @param wsdlPublishLocationMap - Map<String, String>
- */
- public void setWsdlPublishLocationMap(Map wsdlPublishLocationMap)
- {
- this.wsdlPublishLocationMap.clear();
- this.wsdlPublishLocationMap.putAll(wsdlPublishLocationMap);
- }
-
- public boolean isWebServiceDeployment()
- {
- return webServiceDeployment;
- }
-
- public void setWebServiceDeployment(boolean webServiceDeployment)
- {
- this.webServiceDeployment = webServiceDeployment;
- }
-
- public String getJaccContextID()
- {
- return jaccContextID;
- }
-
- public void setJaccContextID(String jaccContextID)
- {
- this.jaccContextID = jaccContextID;
- }
-
- /** Return the optional security-domain jboss-web.xml element.
- @return The jndiName of the security manager implementation that is
- responsible for security of the web application. May be null if
- there was no security-domain specified in the jboss-web.xml
- descriptor.
- */
- public String getSecurityDomain()
- {
- return securityDomain;
- }
-
- /** Set the security domain for this web application
- */
- public void setSecurityDomain(String securityDomain)
- {
- this.securityDomain = securityDomain;
- }
-
- /**
- * JBAS-1824: Specify whether a WebResourcePermission(url,null)
- * needs to be generated by the container
- * @return
- */
- public boolean isJaccRoleNameStar()
- {
- return jaccRoleNameStar;
- }
-
- /**
- * JBAS-1824: Specify whether a WebResourcePermission(url,null)
- * needs to be generated by the container
- * @return
- */
- public void setJaccRoleNameStar(boolean jaccRoleNameStar)
- {
- this.jaccRoleNameStar = jaccRoleNameStar;
- }
-
- /** The flag indicating whether the associated security domain cache
- * should be flushed when the session is invalidated.
- * @return true if the flush should occur, false otherwise.
- */
- public boolean isFlushOnSessionInvalidation()
- {
- return flushOnSessionInvalidation;
- }
-
- /** The flag indicating whether the associated security domain cache
- * should be flushed when the session is invalidated.
- * @param flag - true if the flush should occur, false otherwise.
- */
- public void setFlushOnSessionInvalidation(boolean flag)
- {
- this.flushOnSessionInvalidation = flag;
- }
-
- /** Get the security-constraint settings
- */
- public Iterator getSecurityContraints()
- {
- return securityContraints.iterator();
- }
-
- /**
- *
- * @param securityContraints - Collection<WebSecurityMetaData>
- */
- public void setSecurityConstraints(Collection securityContraints)
- {
- this.securityContraints.clear();
- this.securityContraints.addAll(securityContraints);
- }
-
- /**
- * @return <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
- */
- public Map getSecurityRoleRefs()
- {
- return this.securityRoleReferences;
- }
-
- /**
- *
- * @param servletName
- * @return List<SecurityRoleRefMetaData> for the given servlet name
- */
- public List getSecurityRoleRefs(String servletName)
- {
- List roles = (List) this.securityRoleReferences.get(servletName);
- return roles;
- }
-
- /**
- *
- * @param securityRoleReferences - <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
- */
- public void setSecurityRoleReferences(Map securityRoleReferences)
- {
- this.securityRoleReferences.clear();
- this.securityRoleReferences.putAll(securityRoleReferences);
- }
-
- /**
- * Get the security-role names from the web.xml descriptor
- * @return Set<String> of the security-role names from the web.xml
- */
- public Set getSecurityRoleNames()
- {
- return new HashSet(securityRoles.keySet());
- }
-
- /** Get the optional map of security role/user mapping.
- * @return Map<String, SecurityRoleMetaData>
- */
- public Map getSecurityRoles()
- {
- return new HashMap(securityRoles);
- }
-
- /**
- *
- * @param securityRoles - Map<String, SecurityRoleMetaData>
- */
- public void setSecurityRoles(Map securityRoles)
- {
- this.securityRoles.clear();
- this.securityRoles.putAll(securityRoles);
- }
-
- /**
- *
- * @param userName
- * @return Set<String>
- */
- public Set getSecurityRoleNamesByPrincipal(String userName)
- {
- HashSet roleNames = new HashSet();
- Iterator it = securityRoles.values().iterator();
- while (it.hasNext())
- {
- SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it.next();
- if (srMetaData.getPrincipals().contains(userName))
- roleNames.add(srMetaData.getRoleName());
- }
- return roleNames;
- }
-
- /**
- * Access the RunAsIdentity associated with the given servlet
- * @param servletName - the servlet-name from the web.xml
- * @return RunAsIdentity for the servet if one exists, null otherwise
- */
- public RunAsIdentity getRunAsIdentity(String servletName)
- {
- RunAsIdentity runAs = (RunAsIdentity) runAsIdentity.get(servletName);
- if (runAs == null)
- {
- // Check for a web.xml run-as only specification
- synchronized (runAsIdentity)
- {
- String roleName = (String) runAsNames.get(servletName);
- if (roleName != null)
- {
- runAs = new RunAsIdentity(roleName, null);
- runAsIdentity.put(servletName, runAs);
- }
- }
- }
- return runAs;
- }
-
- /**
- *
- * @return servlet/run-as <String servlet-name, RunAsIdentity>
- */
- public Map getRunAsIdentity()
- {
- return runAsIdentity;
- }
-
- /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity>
- */
- public void setRunAsIdentity(Map runAsIdentity)
- {
- this.runAsIdentity.clear();
- this.runAsIdentity.putAll(runAsIdentity);
- }
-
- /**
- * Get the servlet-name values from the web.xml descriptor
- * @return Set<String> of the servlet-names from the servlet-mappings
- */
- public HashMap getServletMappings()
- {
- return servletMappings;
- }
-
- /** The web.xml servlet-mapping */
- /**
- * servlet-mapping/serlvet-name to url-pattern mapping
- * @param servletMappings - Map<String, String>
- */
- public void setServletMappings(Map servletMappings)
- {
- this.servletMappings.clear();
- this.servletMappings.putAll(servletMappings);
- }
-
- /**
- * Get the servlet-name values from the web.xml descriptor
- * @return Set<String> of the servlet-names from the servlet-mappings
- */
- public Set getServletNames()
- {
- return new HashSet(servletMappings.keySet());
- }
-
- /**
- <<<<<<< .working
- =======
- * Get the init parameter map for a servlet or an empty map if there are none.
- */
- public Map getServletParams(String servletName)
- {
- Map params = (Map) servletParams.get(servletName);
- if (params == null)
- {
- params = new HashMap();
- servletParams.put(servletName, params);
- }
- return params;
- }
-
- /**
- >>>>>>> .merge-right.r68814
- * Get the servlet-name/servlet-class mapping from the web.xml descriptor
- * @return Map<String, String> of the servlet-name/servlet-class mapping from web.xml
- */
- public Map getServletClassMap()
- {
- return new HashMap(servletClassNames);
- }
-
- /**
- * Merge the security role/principal mapping defined in jboss-web.xml
- * with the one defined at jboss-app.xml.
- */
- public void mergeSecurityRoles(Map applRoles)
- {
- Iterator it = applRoles.entrySet().iterator();
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry) it.next();
- String roleName = (String) entry.getKey();
- SecurityRoleMetaData appRole = (SecurityRoleMetaData) entry.getValue();
- SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
- if (srMetaData != null)
- {
- Set principalNames = appRole.getPrincipals();
- srMetaData.addPrincipalNames(principalNames);
- }
- else
- {
- securityRoles.put(roleName, entry.getValue());
- }
- }
- }
-
- /** The servlet container virtual host the war should be deployed into. If
- null then the servlet container default host should be used.
- */
- public Iterator getVirtualHosts()
- {
- return virtualHosts.iterator();
- }
-
- /**
- *
- * @param virtualHosts - Collection<String>
- */
- public void setVirtualHosts(Collection virtualHosts)
- {
- this.virtualHosts.clear();
- this.virtualHosts.addAll(virtualHosts);
- }
-
- /**
- The distributable flag.
- @return true if the web-app is marked distributable
- */
- public boolean getDistributable()
- {
- return distributable;
- }
-
- /**
- * Mark the web-app as distributable
- * @param distributable - true for distributable
- */
- public void setDistributable(boolean distributable)
- {
- this.distributable = distributable;
- }
-
- /** Access the web application depends
- * @return Iterator of JMX ObjectNames the web app depends on.
- */
- public Collection getDepends()
- {
- return depends;
- }
-
- /**
- @param depends - Collection<ObjectName> of the web app dependencies
- */
- public void setDepends(Collection depends)
- {
- this.depends.clear();
- this.depends.addAll(depends);
- }
-
- /** A 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
- */
- public boolean getJava2ClassLoadingCompliance()
- {
- return java2ClassLoadingCompliance;
- }
-
- public void setJava2ClassLoadingCompliance(boolean flag)
- {
- java2ClassLoadingCompliance = flag;
- }
-
- public boolean isUseJBossWebLoader()
- {
- return useJBossWebLoader;
- }
-
- public void setUseJBossWebLoader(boolean flag)
- {
- useJBossWebLoader = flag;
- }
-
- public LoaderRepositoryConfig getLoaderConfig()
- {
- return loaderConfig;
- }
-
- public void setLoaderConfig(LoaderRepositoryConfig loaderConfig)
- {
- this.loaderConfig = loaderConfig;
- }
-
- public ClassLoader getENCLoader()
- {
- return encLoader;
- }
-
- public void setENCLoader(ClassLoader encLoader)
- {
- this.encLoader = encLoader;
- }
-
- public ClassLoader getContextLoader()
- {
- return cxtLoader;
- }
-
- /** Make sure this is called during performDeploy */
- public void setContextLoader(ClassLoader cxtLoader)
- {
- this.cxtLoader = cxtLoader;
- }
-
- public int getSessionCookies()
- {
- return this.sessionCookies;
- }
-
- public void setSessionCookies(int sessionCookies)
- {
- this.sessionCookies = sessionCookies;
- }
-
- public int getInvalidateSessionPolicy()
- {
- return this.invalidateSessionPolicy;
- }
-
- public void setInvalidateSessionPolicy(int invalidateSessionPolicy)
- {
- this.invalidateSessionPolicy = invalidateSessionPolicy;
- }
-
- public int getReplicationType()
- {
- return replicationType;
- }
-
- public int getReplicationGranularity()
- {
- return replicationGranularity;
- }
-
- public void setReplicationGranularity(int replicationGranularity)
- {
- this.replicationGranularity = replicationGranularity;
- }
-
- public boolean getReplicationFieldBatchMode()
- {
- return replicationFieldBatchMode;
- }
-
- public void importXml(Element element) throws DeploymentException
- {
- String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
- if (rootTag.equals("web-app"))
- {
- importWebXml(element);
- }
- else if (rootTag.equals("jboss-web"))
- {
- importJBossWebXml(element);
- }
- }
-
- /** Parse the elements of the web-app element used by the integration layer.
- */
- protected void importWebXml(Element webApp) throws DeploymentException
- {
- // Parse the web-app/servlet/security-role-ref + run-as elements
- Iterator iterator = getChildrenByTagName(webApp, "servlet");
- while (iterator.hasNext())
- {
- Element servlet = (Element) iterator.next();
- String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
- String servletClass = getElementContent(getOptionalChild(servlet, "servlet-class"));
- if (servletClass != null)
- {
- servletClassNames.put(servletName, servletClass);
- }
-
- Iterator initParams = getChildrenByTagName(servlet, "init-param");
- while (initParams.hasNext())
- {
- Element param = (Element) initParams.next();
- String paramName = getElementContent(getUniqueChild(param, "param-name"));
- String paramValue = getElementContent(getUniqueChild(param, "param-value"));
-
- if (null == servletParams.get(servletName))
- {
- servletParams.put(servletName, new HashMap());
- }
-
- ((Map) servletParams.get(servletName)).put(paramName, paramValue);
- }
-
- Iterator roleRefs = getChildrenByTagName(servlet, "security-role-ref");
- ArrayList roleNames = new ArrayList();
- while (roleRefs.hasNext())
- {
- Element roleRefElem = (Element) roleRefs.next();
- SecurityRoleRefMetaData roleRef = new SecurityRoleRefMetaData();
- roleRef.importEjbJarXml(roleRefElem);
- roleNames.add(roleRef);
- }
- securityRoleReferences.put(servletName, roleNames);
-
- // Check for a run-as/role-name
- Element runAs = getOptionalChild(servlet, "run-as");
- if (runAs != null)
- {
- String runAsName = getElementContent(getOptionalChild(runAs, "role-name"));
- runAsNames.put(servletName, runAsName);
- }
- }
-
- // Parse the web-app/context-param elements
- iterator = getChildrenByTagName(webApp, "context-param");
- while (iterator.hasNext())
- {
- Element contextParam = (Element) iterator.next();
- String paramName = getElementContent(getUniqueChild(contextParam, "param-name"));
- String paramValue = getElementContent(getUniqueChild(contextParam, "param-value"));
- contextParams.put(paramName, paramValue);
- }
-
- // Parse the web-app/servlet-mapping elements
- iterator = getChildrenByTagName(webApp, "servlet-mapping");
- while (iterator.hasNext())
- {
- Element servletMapping = (Element) iterator.next();
- String servletName = getElementContent(getUniqueChild(servletMapping, "servlet-name"));
- String urlPattern = getElementContent(getUniqueChild(servletMapping, "url-pattern"));
- servletMappings.put(servletName, urlPattern);
- }
-
- // Parse the web-app/resource-ref elements
- iterator = getChildrenByTagName(webApp, "resource-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
- resourceRefMetaData.importEjbJarXml(resourceRef);
- resourceReferences.put(resourceRefMetaData.getRefName(), resourceRefMetaData);
- }
-
- // Parse the resource-env-ref elements
- iterator = getChildrenByTagName(webApp, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
- refMetaData.importEjbJarXml(resourceRef);
- resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
- }
-
- // set the message destination references
- iterator = getChildrenByTagName(webApp, "message-destination-ref");
- while (iterator.hasNext())
- {
- Element messageDestinationRef = (Element) iterator.next();
- MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
- messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
- messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
- }
-
- // set the message destinations (optional)
- iterator = getChildrenByTagName(webApp, "message-destination");
- while (iterator.hasNext())
- {
- Element messageDestination = (Element) iterator.next();
- try
- {
- MessageDestinationMetaData messageDestinationMetaData = new MessageDestinationMetaData();
- messageDestinationMetaData.importEjbJarXml(messageDestination);
- messageDestinations.put(messageDestinationMetaData.getName(), messageDestinationMetaData);
- }
- catch (Throwable t)
- {
- throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
- }
- }
-
- // Parse the web-app/env-entry elements
- iterator = getChildrenByTagName(webApp, "env-entry");
- while (iterator.hasNext())
- {
- Element envEntry = (Element) iterator.next();
- EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
- envEntryMetaData.importEjbJarXml(envEntry);
- environmentEntries.add(envEntryMetaData);
- }
-
- // Get the security-constraints
- iterator = getChildrenByTagName(webApp, "security-constraint");
- while (iterator.hasNext())
- {
- Element contraints = (Element) iterator.next();
- WebSecurityMetaData wsmd = new WebSecurityMetaData();
- securityContraints.add(wsmd);
- // Process the web-resource-collections
- Iterator iter2 = getChildrenByTagName(contraints, "web-resource-collection");
- while (iter2.hasNext())
- {
- Element wrcElement = (Element) iter2.next();
- Element wrName = getUniqueChild(wrcElement, "web-resource-name");
- String name = getElementContent(wrName);
- WebSecurityMetaData.WebResourceCollection wrc = wsmd.addWebResource(name);
- Iterator iter21 = getChildrenByTagName(wrcElement, "url-pattern");
- while (iter21.hasNext())
- {
- Element urlPattern = (Element) iter21.next();
- String pattern = getElementContent(urlPattern);
- wrc.addPattern(pattern);
- }
-
- Iterator iter22 = getChildrenByTagName(wrcElement, "http-method");
- while (iter22.hasNext())
- {
- Element httpMethod = (Element) iter22.next();
- String method = getElementContent(httpMethod);
- wrc.addHttpMethod(method);
- }
- }
-
- // Process the auth-constraints
- Element authContraint = getOptionalChild(contraints, "auth-constraint");
- if (authContraint != null)
- {
- Iterator iter3 = getChildrenByTagName(authContraint, "role-name");
- while (iter3.hasNext())
- {
- Element roleName = (Element) iter3.next();
- String name = getElementContent(roleName);
- wsmd.addRole(name);
- }
- if (wsmd.getRoles().size() == 0)
- wsmd.setExcluded(true);
- }
- else
- {
- wsmd.setUnchecked(true);
- }
-
- // Process the user-data-constraint
- Element userData = getOptionalChild(contraints, "user-data-constraint");
- if (userData != null)
- {
- Element transport = getUniqueChild(userData, "transport-guarantee");
- String type = getElementContent(transport);
- wsmd.setTransportGuarantee(type);
- }
- }
-
- // Get the web-app/security-role elements (optional)
- iterator = getChildrenByTagName(webApp, "security-role");
- while (iterator.hasNext())
- {
- Element securityRole = (Element) iterator.next();
- String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
- securityRoles.put(roleName, new SecurityRoleMetaData(roleName));
- }
-
- // Parse the web-app/ejb-ref elements
- iterator = getChildrenByTagName(webApp, "ejb-ref");
- while (iterator.hasNext())
- {
- Element ejbRef = (Element) iterator.next();
- EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
- ejbRefMetaData.importEjbJarXml(ejbRef);
- ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
- }
-
- // Parse the web-app/ejb-local-ref elements
- iterator = getChildrenByTagName(webApp, "ejb-local-ref");
- while (iterator.hasNext())
- {
- Element ejbRef = (Element) iterator.next();
- EjbLocalRefMetaData ejbRefMetaData = new EjbLocalRefMetaData();
- ejbRefMetaData.importEjbJarXml(ejbRef);
- ejbLocalReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(webApp, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element) iterator.next();
- ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
- refMetaData.importStandardXml(serviceRef);
- serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
- }
-
- // Is the web-app marked distributable?
- iterator = getChildrenByTagName(webApp, "distributable");
- if (iterator.hasNext())
- {
- distributable = true;
- }
- }
-
- /** Parse the elements of the jboss-web element used by the integration layer.
- */
- protected void importJBossWebXml(Element jbossWeb) throws DeploymentException
- {
- // Parse the jboss-web/root-context element
- Element contextRootElement = getOptionalChild(jbossWeb, "context-root");
- if (contextRootElement != null)
- contextRoot = getElementContent(contextRootElement);
-
- // Parse the jboss-web/security-domain element
- Element securityDomainElement = getOptionalChild(jbossWeb, "security-domain");
- if (securityDomainElement != null)
- {
- securityDomain = getElementContent(securityDomainElement);
- // Check the flushOnSessionInvalidation attribute
- Boolean flag = Boolean.valueOf(securityDomainElement.getAttribute("flushOnSessionInvalidation"));
- flushOnSessionInvalidation = flag.booleanValue();
- }
-
- //Parse the jboss-web/jacc-star-role-allow element
- Element jaccStarRoleElement = getOptionalChild(jbossWeb, "jacc-star-role-allow");
- if (jaccStarRoleElement != null)
- {
- jaccRoleNameStar = "true".equalsIgnoreCase(getElementContent(jaccStarRoleElement));
- }
-
- // Parse the jboss-web/virtual-host elements
- for (Iterator virtualHostElements = getChildrenByTagName(jbossWeb, "virtual-host"); virtualHostElements.hasNext();)
- {
- Element virtualHostElement = (Element) virtualHostElements.next();
- String virtualHostName = getElementContent(virtualHostElement);
- virtualHosts.add(virtualHostName);
- } // end of for ()
-
- // Parse the jboss-web/resource-ref elements
- Iterator iterator = getChildrenByTagName(jbossWeb, "resource-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
- ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences.get(resRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("resource-ref " + resRefName + " found in jboss-web.xml but not in web.xml");
- }
- refMetaData.importJbossXml(resourceRef);
- }
-
- // Parse the jboss-web/resource-env-ref elements
- iterator = getChildrenByTagName(jbossWeb, "resource-env-ref");
- while (iterator.hasNext())
- {
- Element resourceRef = (Element) iterator.next();
- String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
- ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("resource-env-ref " + resRefName
- + " found in jboss-web.xml but not in web.xml");
- }
- refMetaData.importJbossXml(resourceRef);
- }
-
- // update the message destination references (optional)
- iterator = getChildrenByTagName(jbossWeb, "message-destination-ref");
- while (iterator.hasNext())
- {
- Element messageDestinationRef = (Element) iterator.next();
- String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef,
- "message-destination-ref-name"));
- MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences
- .get(messageDestinationRefName);
- if (messageDestinationRefMetaData == null)
- throw new DeploymentException("message-destination-ref " + messageDestinationRefName
- + " found in jboss-web.xml but not in web.xml");
- messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
- }
-
- // set the message destinations (optional)
- iterator = getChildrenByTagName(jbossWeb, "message-destination");
- while (iterator.hasNext())
- {
- Element messageDestination = (Element) iterator.next();
- try
- {
- String messageDestinationName = getUniqueChildContent(messageDestination, "message-destination-name");
- MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations
- .get(messageDestinationName);
- if (messageDestinationMetaData == null)
- throw new DeploymentException("message-destination " + messageDestinationName
- + " found in jboss-web.xml but not in web.xml");
- messageDestinationMetaData.importJbossXml(messageDestination);
- }
- catch (Throwable t)
- {
- throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
- }
- }
-
- // set the security roles (optional)
- iterator = getChildrenByTagName(jbossWeb, "security-role");
- while (iterator.hasNext())
- {
- Element securityRole = (Element) iterator.next();
- String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
- SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
- if (securityRoleMetaData == null)
- throw new DeploymentException("Security role '" + roleName + "' defined in jboss-web.xml"
- + " is not defined in web.xml");
-
- Iterator itPrincipalNames = getChildrenByTagName(securityRole, "principal-name");
- while (itPrincipalNames.hasNext())
- {
- String principalName = getElementContent((Element) itPrincipalNames.next());
- securityRoleMetaData.addPrincipalName(principalName);
- }
- }
-
- // Parse the jboss-web/ejb-ref elements
- iterator = getChildrenByTagName(jbossWeb, "ejb-ref");
- while (iterator.hasNext())
- {
- Element ejbRef = (Element) iterator.next();
- String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
- if (ejbRefMetaData == null)
- {
- throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss-web.xml but not in web.xml");
- }
- ejbRefMetaData.importJbossXml(ejbRef);
- }
-
- // Parse the jboss-web/ejb-local-ref elements
- iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref");
- while (iterator.hasNext())
- {
- Element ejbLocalRef = (Element) iterator.next();
- String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
- EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences.get(ejbLocalRefName);
- if (ejbLocalRefMetaData == null)
- {
- throw new DeploymentException("ejb-local-ref " + ejbLocalRefName
- + " found in jboss-web.xml but not in web.xml");
- }
- ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
- }
-
- // Parse the service-ref elements
- iterator = MetaData.getChildrenByTagName(jbossWeb, "service-ref");
- while (iterator.hasNext())
- {
- Element serviceRef = (Element) iterator.next();
- String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
- ServiceRefMetaData refMetaData = (ServiceRefMetaData) serviceReferences.get(serviceRefName);
- if (refMetaData == null)
- {
- throw new DeploymentException("service-ref " + serviceRefName
- + " found in jboss-web.xml but not in web.xml");
- }
- refMetaData.importJBossXml(serviceRef);
- }
-
- // WebserviceDescriptions
- iterator = getChildrenByTagName(jbossWeb, "webservice-description");
- while (iterator.hasNext())
- {
- Element wsd = (Element) iterator.next();
- String wsdName = getElementContent(getUniqueChild(wsd, "webservice-description-name"));
- configName = MetaData.getOptionalChildContent(wsd, "config-name");
- configFile = MetaData.getOptionalChildContent(wsd, "config-file");
- String wsdlPublishLocation = getOptionalChildContent(wsd, "wsdl-publish-location");
- wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation);
- }
-
- // Parse the jboss-web/depends elements
- for (Iterator dependsElements = getChildrenByTagName(jbossWeb, "depends"); dependsElements.hasNext();)
- {
- Element dependsElement = (Element) dependsElements.next();
- String dependsName = getElementContent(dependsElement);
- depends.add(ObjectNameFactory.create(dependsName));
- } // end of for ()
-
- // Parse the jboss-web/use-session-cookies element
- iterator = getChildrenByTagName(jbossWeb, "use-session-cookies");
- if (iterator.hasNext())
- {
- Element useCookiesElement = (Element) iterator.next();
- String useCookiesElementContent = getElementContent(useCookiesElement);
- Boolean useCookies = Boolean.valueOf(useCookiesElementContent);
-
- if (useCookies.booleanValue())
- {
- sessionCookies = SESSION_COOKIES_ENABLED;
- }
- else
- {
- sessionCookies = SESSION_COOKIES_DISABLED;
- }
- }
-
- // Parse the jboss-web/session-replication element
-
- Element sessionReplicationRootElement = getOptionalChild(jbossWeb, "replication-config");
- if (sessionReplicationRootElement != null)
- {
- // manage "replication-trigger" first ...
- //
- Element replicationTriggerElement = getOptionalChild(sessionReplicationRootElement, "replication-trigger");
- if (replicationTriggerElement != null)
- {
- String repMethod = getElementContent(replicationTriggerElement);
- if ("SET_AND_GET".equalsIgnoreCase(repMethod))
- this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET;
- else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(repMethod))
- this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
- else if ("SET".equalsIgnoreCase(repMethod))
- this.invalidateSessionPolicy = SESSION_INVALIDATE_SET;
- else
- throw new DeploymentException("replication-trigger value set to a non-valid value: '" + repMethod
- + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml");
- }
-
- // ... then manage "replication-type".
- //
- Element replicationTypeElement = getOptionalChild(sessionReplicationRootElement, "replication-type");
- if (replicationTypeElement != null)
- {
- String repType = getElementContent(replicationTypeElement);
- if ("SYNC".equalsIgnoreCase(repType))
- this.replicationType = REPLICATION_TYPE_SYNC;
- else if ("ASYNC".equalsIgnoreCase(repType))
- this.replicationType = REPLICATION_TYPE_ASYNC;
- else
- throw new DeploymentException("replication-type value set to a non-valid value: '" + repType
- + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml");
- }
-
- // ... then manage "replication-type".
- //
- Element replicationGranularityElement = MetaData.getOptionalChild(sessionReplicationRootElement,
- "replication-granularity");
- if (replicationGranularityElement != null)
- {
- String repType = MetaData.getElementContent(replicationGranularityElement);
- if ("SESSION".equalsIgnoreCase(repType))
- this.replicationGranularity = REPLICATION_GRANULARITY_SESSION;
- else if ("ATTRIBUTE".equalsIgnoreCase(repType))
- this.replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE;
- else if ("FIELD".equalsIgnoreCase(repType))
- this.replicationGranularity = REPLICATION_GRANULARITY_FIELD;
- else
- throw new DeploymentException("replication-granularity value set to a non-valid value: '" + repType
- + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml");
- }
-
- Element batchModeElement = MetaData.getOptionalChild(sessionReplicationRootElement,
- "replication-field-batch-mode");
- if (batchModeElement != null)
- {
- Boolean flag = Boolean.valueOf(MetaData.getElementContent(batchModeElement));
- replicationFieldBatchMode = flag.booleanValue();
- }
- }
-
- // Check for a war level class loading config
- Element classLoading = MetaData.getOptionalChild(jbossWeb, "class-loading");
- if (classLoading != null)
- {
- String flagString = classLoading.getAttribute("java2ClassLoadingCompliance");
- if (flagString.length() == 0)
- flagString = "true";
- boolean flag = Boolean.valueOf(flagString).booleanValue();
- setJava2ClassLoadingCompliance(flag);
- // Check for a loader-repository for scoping
- Element loader = MetaData.getOptionalChild(classLoading, "loader-repository");
- if (loader != null)
- {
- useJBossWebLoader = true;
- try
- {
- loaderConfig = LoaderRepositoryFactory.parseRepositoryConfig(loader);
- }
- catch (MalformedObjectNameException e)
- {
- throw new DeploymentException(e);
- }
- }
- }
-
- // Parse the jboss-web/servlet elements
- iterator = getChildrenByTagName(jbossWeb, "servlet");
- while (iterator.hasNext())
- {
- Element servlet = (Element) iterator.next();
- String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
- String principalName = getOptionalChildContent(servlet, "run-as-principal");
- // Get the web.xml run-as primary role
- String webXmlRunAs = (String) runAsNames.get(servletName);
- if (principalName != null)
- {
- if (webXmlRunAs == null)
- {
- throw new DeploymentException("run-as-principal: " + principalName
- + " found in jboss-web.xml but there was no run-as in web.xml");
- }
- // See if there are any additional roles for this principal
- Set extraRoles = getSecurityRoleNamesByPrincipal(principalName);
- RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, principalName, extraRoles);
- runAsIdentity.put(servletName, runAs);
- }
- else if (webXmlRunAs != null)
- {
- RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, null);
- runAsIdentity.put(servletName, runAs);
- }
- }
-
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefDelegate.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.metadata.serviceref;
-
-// $Id$
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.registry.KernelRegistry;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.jboss.wsf.spi.util.KernelLocator;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.w3c.dom.Element;
-import org.xml.sax.Attributes;
-
-/**
- * Factory for ServiceRefHandler
- *
- * @author Thomas.Diesler at jboss.org
- * @since 05-May-2004
- */
-public class ServiceRefDelegate implements ServiceRefHandler
-{
- // provide logging
- private static final Logger log = Logger.getLogger(ServiceRefDelegate.class);
-
- private static ServiceRefHandler delegate;
-
- public ServiceRefDelegate()
- {
- if (delegate == null)
- {
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- delegate = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
- }
-
- if (delegate == null)
- log.warn("Not registered: " + ServiceRefHandler.BEAN_NAME);
- }
-
- public ServiceRefMetaData newServiceRefMetaData()
- {
- ServiceRefMetaData sref;
- if (delegate != null)
- sref = delegate.newServiceRefMetaData();
- else
- sref = new DummyServiceRef();
- return sref;
- }
-
- public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (delegate != null)
- child = delegate.newChild(ref, navigator, namespaceURI, localName, attrs);
- return child;
- }
-
- public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- if (delegate != null)
- delegate.setValue(ref, navigator, namespaceURI, localName, value);
- }
-
- public void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader, ServiceRefMetaData sref) throws NamingException
- {
- if (delegate != null)
- delegate.bindServiceRef(encCtx, encName, vfsRoot, loader, sref);
- }
-
- public static class DummyServiceRef extends ServiceRefMetaData
- {
- private String refName;
-
- @Override
- public void setServiceRefName(String name)
- {
- this.refName = name;
- }
-
- @Override
- public String getServiceRefName()
- {
- return refName;
- }
-
- @Override
- public Object getAnnotatedElement()
- {
- return null;
- }
-
- @Override
- public void setAnnotatedElement(Object anElement)
- {
- }
-
- @Override
- public void importJBossXml(Element element)
- {
- }
-
- @Override
- public void importStandardXml(Element element)
- {
- }
-
- @Override
- public boolean isProcessed()
- {
- return false;
- }
-
- @Override
- public void setProcessed(boolean flag)
- {
- }
-
- @Override
- public void merge(ServiceRefMetaData serviceRef)
- {
- }
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.metadata.serviceref;
-
-// $Id$
-
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.serviceref.ServiceRefElement;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.xml.sax.Attributes;
-
-/**
- * A object model factory for <service-ref>
- *
- * @author Thomas.Diesler at jboss.com
- */
-public abstract class ServiceRefObjectFactory implements ObjectModelFactory
-{
- // provide logging
- private static Logger log = Logger.getLogger(ServiceRefObjectFactory.class);
-
-
- public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
- {
- return new ServiceRefDelegate().newChild(ref, navigator, namespaceURI, localName, attrs);
- }
-
- public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
- {
- new ServiceRefDelegate().setValue(ref, navigator, namespaceURI, localName, value);
- }
-
- public static boolean isJ2EE14Descriptor(Element element)
- {
- // Verify J2EE-1.4
- String nsURI = element.getOwnerDocument().getDocumentElement().getNamespaceURI();
- boolean isValid = "http://java.sun.com/xml/ns/j2ee".equals(nsURI);
-
- // Verify JBoss-4.0
- DocumentType doctype = element.getOwnerDocument().getDoctype();
- if (isValid == false && doctype != null)
- {
- String publicId = doctype.getPublicId();
- isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
- isValid |= "-//JBoss//DTD JBOSS 4.2//EN".equals(publicId);
- isValid |= "-//JBoss//DTD Web Application 2.4//EN".equals(publicId);
- isValid |= "-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
- isValid |= "-//JBoss//DTD Application Client 4.2//EN".equals(publicId);
- }
-
- if (isValid == false)
- {
- String dtstr = (doctype != null ? "[public=" + doctype.getPublicId() + ",system=" + doctype.getSystemId() + "]" : null);
- log.debug("Skip <service-ref> for: nsURI=" + nsURI + ",doctype=" + dtstr);
- }
- return isValid;
- }
-}
Deleted: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/web/AbstractWebDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/web/AbstractWebDeployer.java 2008-06-25 17:14:25 UTC (rev 75079)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/web/AbstractWebDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -1,885 +0,0 @@
-/*
- * 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.web;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.Policy;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NamingException;
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.deployment.J2eeApplicationMetaData;
-import org.jboss.ejb.Container;
-import org.jboss.ejb.EjbUtil;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.EjbLocalRefMetaData;
-import org.jboss.metadata.EjbRefMetaData;
-import org.jboss.metadata.EnvEntryMetaData;
-import org.jboss.metadata.MessageDestinationMetaData;
-import org.jboss.metadata.MessageDestinationRefMetaData;
-import org.jboss.metadata.ResourceEnvRefMetaData;
-import org.jboss.metadata.ResourceRefMetaData;
-import org.jboss.metadata.WebMetaData;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.util.naming.NonSerializableFactory;
-import org.jboss.util.naming.Util;
-import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
-import org.jboss.wsf.common.URLLoaderAdapter;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.omg.CORBA.ORB;
-
-/** A template pattern class for web deployer integration into JBoss. This class
-should be subclasses by war deployers providers wishing to integrate into
-a JBoss server.
-
-It provides support for mapping the following web-app.xml/jboss-web.xml elements
-into the JBoss server JNDI namespace:
-- env-entry
-- resource-ref
-- resource-env-ref
-- ejb-ref
-- ejb-local-ref
-- security-domain
-
-Subclasses need to implement the {@link #performDeploy(WebApplication, String,
- WebDescriptorParser) performDeploy()}
-and {@link #performUndeploy(String, WebApplication) performUndeploy()} methods to perform the
-container specific steps and return the web application info required by the
-AbstractWebContainer class.
-
-Integration with the JBossSX security framework is based on the establishment
-of a java:comp/env/security context as described in the
-{@link #linkSecurityDomain(String,Context) linkSecurityDomain } comments.
-The security context provides access to the JBossSX security mgr interface
-implementations for use by subclass request interceptors. A outline of the
-steps for authenticating a user is:
-<code>
- // Get the username & password from the request context...
- String username = f(request);
- String password = f(request);
- // Get the JBoss security manager from the ENC context
- InitialContext iniCtx = new InitialContext();
- SecurityManager securityMgr = (SecurityManager) iniCtx.lookup("java:comp/env/security/securityMgr");
- SimplePrincipal principal = new SimplePrincipal(username);
- if( securityMgr.isValid(principal, password) )
- {
- // Indicate the user is allowed access to the web content...
-
- // Propagate the user info to JBoss for any calls into made by the servlet
- SecurityAssociation.setPrincipal(principal);
- SecurityAssociation.setCredential(password.toCharArray());
- }
- else
- {
- // Deny access...
- }
-</code>
-
-An outline of the steps for authorizing the user is:
-<code>
- // Get the username & required roles from the request context...
- String username = f(request);
- String[] roles = f(request);
- // Get the JBoss security manager from the ENC context
- InitialContext iniCtx = new InitialContext();
- RealmMapping securityMgr = (RealmMapping) iniCtx.lookup("java:comp/env/security/realmMapping");
- SimplePrincipal principal = new SimplePrincipal(username);
- Set requiredRoles = new HashSet(Arrays.asList(roles));
- if( securityMgr.doesUserHaveRole(principal, requiredRoles) )
- {
- // Indicate the user has the required roles for the web content...
- }
- else
- {
- // Deny access...
- }
-</code>
-
-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. If your adapting a web container that is trying be compatible with
-both 1.1 and 1.2 Java VMs this is something you need to pay special attention
-to. For example, I have seen problems a request interceptor that was handling
-the authentication/authorization callouts in tomcat3.2.1 not having the same
-thread context ClassLoader as was used to dispatch the http service request.
-
- at see #performDeploy(WebApplication webApp, String warUrl,
- WebDescriptorParser webAppParser)
- at see #performUndeploy(String, WebApplication)
- at see #parseWebAppDescriptors(DeploymentInfo,ClassLoader, WebMetaData)
- at see #linkSecurityDomain(String, Context)
- at see org.jboss.security.RealmMapping;
- at see org.jboss.security.SimplePrincipal;
- at see org.jboss.security.SecurityAssociation;
-
- at jmx.mbean
- name="jboss.web:service=WebServer"
- extends="org.jboss.deployment.SubDeployerMBean"
-
- at author Scott.Stark at jboss.org
- at version $Revision$
-*/
-public abstract class AbstractWebDeployer
-{
- public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
- protected Logger log;
-
- protected MBeanServer server;
- /** 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;
-
- public AbstractWebDeployer()
- {
- log = Logger.getLogger(getClass());
- }
-
- public abstract void init(Object containerConfig) throws Exception;
-
- public MBeanServer getServer()
- {
- return server;
- }
- public void setServer(MBeanServer server)
- {
- this.server = server;
- }
-
- /** 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 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()
- {
- 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;
- }
-
- /** 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
- webAppParser.parseWebAppDescriptors(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 di 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(DeploymentInfo di) throws DeploymentException
- {
- Thread thread = Thread.currentThread();
- ClassLoader appClassLoader = thread.getContextClassLoader();
- WebApplication warInfo = null;
- try
- {
- // Create a classloader for the war to ensure a unique ENC
- URL[] empty = {};
- URLClassLoader warLoader = URLClassLoader.newInstance(empty, di.ucl);
- thread.setContextClassLoader(warLoader);
- WebDescriptorParser webAppParser = new DescriptorParser(di);
- String webContext = di.webContext;
- if (webContext != null && webContext.startsWith("/") == false)
- webContext = "/" + webContext;
-
- // Get the war URL
- URL warURL = di.localUrl != null ? di.localUrl : di.url;
-
- if (log.isDebugEnabled())
- {
- log.debug("webContext: " + webContext);
- log.debug("warURL: " + warURL);
- log.debug("webAppParser: " + webAppParser);
- }
-
- // Get the web.xml and jboss-web.xml descriptor metadata
- WebMetaData webMetaData = (WebMetaData) di.metaData;
-
- // inherit the security setup from jboss-app.xml
- if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
- {
- J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData)di.parent.metaData;
-
- if (webMetaData.getSecurityDomain() == null)
- webMetaData.setSecurityDomain(appMetaData.getSecurityDomain());
-
- webMetaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
- }
-
- // Register the permissions with the JACC layer
- String contextID = di.shortName;
- if( contextID == null )
- contextID = di.shortName;
- webMetaData.setJaccContextID(contextID);
- PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
- createPermissions(webMetaData, pc);
- // Link this to the parent PC
- DeploymentInfo current = di;
- while( current.parent != null )
- current = current.parent;
- PolicyConfiguration parentPC = (PolicyConfiguration)
- current.context.get("javax.security.jacc.PolicyConfiguration");
- if( parentPC != null && parentPC != pc )
- parentPC.linkConfiguration(pc);
-
- // Commit the policy configuration
- pc.commit();
- // Allow the policy to incorporate the policy configs
- Policy.getPolicy().refresh();
-
- warInfo = new WebApplication(webMetaData);
- warInfo.setDeploymentInfo(di);
- warInfo.setClassLoader(warLoader);
- performDeploy(warInfo, warURL.toString(), webAppParser);
- }
- catch(DeploymentException e)
- {
- di.context.put(ERROR, e);
- throw e;
- }
- catch(Exception e)
- {
- DeploymentException ex = new DeploymentException("Error during deploy", e);
- di.context.put(ERROR, ex);
- throw ex;
- }
- finally
- {
- thread.setContextClassLoader(appClassLoader);
- }
- return warInfo;
- }
-
- /** This method is called by the deploy() 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.
- @param webAppParser The callback interface the web container should use to
- setup the web app JNDI environment for use by the web app components. This
- needs to be invoked after the web app class loader is known, but before
- and web app components attempt to access the java:comp/env JNDI namespace.
- */
- protected abstract void performDeploy(WebApplication webApp, String warUrl,
- WebDescriptorParser webAppParser) throws Exception;
-
- /** 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(DeploymentInfo di)
- throws DeploymentException
- {
- URL warURL = di.localUrl != null ? di.localUrl : di.url;
- String warUrl = warURL.toString();
- try
- {
- WebApplication webApp = (WebApplication) di.context.get(AbstractWebContainer.WEB_APP);
- performUndeploy(warUrl, webApp);
- // Unegister the permissions with the JACC layer
- WebMetaData webMetaData = (WebMetaData) di.metaData;
- String contextID = webMetaData.getJaccContextID();
- PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
- pc.delete();
- }
- catch(DeploymentException e)
- {
- throw e;
- }
- catch(Exception e)
- {
- throw new DeploymentException("Error during deploy", e);
- }
- }
-
- /** Called as part of the undeploy() method template to ask the
- subclass for perform the web container specific undeployment steps.
- */
- protected abstract void performUndeploy(String warUrl, WebApplication webApp)
- 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 parseWebAppDescriptors(DeploymentInfo di, ClassLoader loader,
- WebMetaData metaData)
- throws Exception
- {
- log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
- InitialContext iniCtx = new InitialContext();
- Context envCtx = null;
- Thread currentThread = Thread.currentThread();
- ClassLoader currentLoader = currentThread.getContextClassLoader();
- 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: Where does this ENC get tidied up?
- currentThread.setContextClassLoader(loader);
- metaData.setENCLoader(loader);
- envCtx = (Context) iniCtx.lookup("java:comp");
-
- ORB orb = null;
- try
- {
- orb = (ORB) server.getAttribute(Container.ORB_NAME, "ORB");
- }
- catch (Throwable t)
- {
- log.debug("Unable to retrieve orb" + t.toString());
- }
-
- // Bind the orb
- if (orb != null)
- {
- NonSerializableFactory.rebind(envCtx, "ORB", orb);
- log.debug("Bound java:comp/ORB");
- }
-
- // 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");
- }
- finally
- {
- currentThread.setContextClassLoader(currentLoader);
- }
-
- Iterator envEntries = metaData.getEnvironmentEntries();
- log.debug("addEnvEntries");
- addEnvEntries(envEntries, envCtx);
- Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
- log.debug("linkResourceEnvRefs");
- linkResourceEnvRefs(resourceEnvRefs, envCtx);
- Iterator resourceRefs = metaData.getResourceReferences();
- log.debug("linkResourceRefs");
- linkResourceRefs(resourceRefs, envCtx);
- log.debug("linkMessageDestinationRefs");
- linkMessageDestinationRefs(metaData, envCtx, di);
- Iterator ejbRefs = metaData.getEjbReferences();
- log.debug("linkEjbRefs");
- linkEjbRefs(ejbRefs, envCtx, di);
- Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
- log.debug("linkEjbLocalRefs");
- linkEjbLocalRefs(ejbLocalRefs, envCtx, di);
- log.debug("linkServiceRefs");
- linkServiceRefs(metaData, envCtx, di);
- String securityDomain = metaData.getSecurityDomain();
- log.debug("linkSecurityDomain");
- linkSecurityDomain(securityDomain, envCtx);
- log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
- }
-
- private void linkServiceRefs(WebMetaData metaData, Context envCtx, DeploymentInfo di) throws NamingException
- {
- UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
- for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
- {
- String refName = sref.getServiceRefName();
- new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
- }
- }
-
- protected void addEnvEntries(Iterator envEntries, Context envCtx)
- throws ClassNotFoundException, NamingException
- {
- while( envEntries.hasNext() )
- {
- EnvEntryMetaData entry = (EnvEntryMetaData) envEntries.next();
- log.debug("Binding env-entry: "+entry.getName()+" of type: " +
- entry.getType()+" to value:"+entry.getValue());
- EnvEntryMetaData.bindEnvEntry(envCtx, entry);
- }
- }
-
- protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
- throws NamingException
- {
- while( resourceEnvRefs.hasNext() )
- {
- ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData) resourceEnvRefs.next();
- String resourceName = ref.getJndiName();
- String refName = ref.getRefName();
- 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(Iterator resourceRefs, Context envCtx)
- throws NamingException
- {
- while( resourceRefs.hasNext() )
- {
- ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
- String jndiName = ref.getJndiName();
- String refName = ref.getRefName();
- if( ref.getType().equals("java.net.URL") )
- {
- try
- {
- String resURL = ref.getResURL();
- if( ref.getResURL() != 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(WebMetaData metaData, Context envCtx, DeploymentInfo di)
- throws NamingException, DeploymentException
- {
- Iterator i = metaData.getMessageDestinationReferences();
-
- while (i.hasNext())
- {
- MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
-
- String refName = ref.getRefName();
- String jndiName = ref.getJNDIName();
- String link = ref.getLink();
- if (link != null)
- {
- if (jndiName == null)
- {
- MessageDestinationMetaData messageDestination = EjbUtil.findMessageDestination(server, di, link);
- if (messageDestination == null)
- throw new DeploymentException("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 DeploymentException("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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
- throws NamingException
- {
- while( ejbRefs.hasNext() )
- {
- EjbRefMetaData ejb = (EjbRefMetaData) ejbRefs.next();
- String name = ejb.getName();
- String linkName = ejb.getLink();
- String jndiName = null;
-
- //use ejb-link if it is specified
- if ( linkName != null )
- {
- jndiName = EjbUtil.findEjbLink(server, di, 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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
- throws NamingException
- {
- while( ejbRefs.hasNext() )
- {
- EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
- String name = ejb.getName();
- String linkName = ejb.getLink();
- String jndiName = null;
-
- //use the ejb-link field if it is specified
- if ( linkName != null )
- {
- jndiName = EjbUtil.findLocalEjbLink(server, di, 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);
- }
- 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));
- 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 = AbstractWebContainer.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());
- }
- }
-
- /** Create the JACC permission based on the security constraints obtained
- * from the web.xml metadata.
- *
- * @param metaData
- * @param pc
- * @throws PolicyContextException
- */
- protected void createPermissions(WebMetaData metaData, PolicyConfiguration pc)
- throws PolicyContextException
- {
- WebPermissionMapping.createPermissions(metaData, pc);
- }
-
- /** An inner class that maps the WebDescriptorParser.parseWebAppDescriptors()
- onto the protected parseWebAppDescriptors() AbstractWebContainer method.
- */
- private class DescriptorParser implements WebDescriptorParser
- {
- DeploymentInfo di;
- DescriptorParser(DeploymentInfo di)
- {
- this.di = di;
- }
- public void parseWebAppDescriptors(ClassLoader loader, WebMetaData metaData)
- throws Exception
- {
- AbstractWebDeployer.this.parseWebAppDescriptors(di, loader, metaData);
- }
- public DeploymentInfo getDeploymentInfo()
- {
- return di;
- }
- }
-}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/deployment/ClientDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/deployment/ClientDeployer.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/deployment/ClientDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,332 @@
+/*
+ * 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.deployment;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+
+import org.jboss.ejb.EjbUtil;
+import org.jboss.metadata.ClientMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.XmlFileLoader;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.util.naming.Util;
+import org.jboss.ws.integration.URLLoaderAdapter;
+import org.jboss.ws.integration.UnifiedVirtualFile;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+/**
+ * An XMBean resource implementation of a deployer for j2ee application
+ * client jars
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 69712 $
+ */
+public class ClientDeployer extends SubDeployerSupport
+{
+ protected void startService() throws Exception
+ {
+ // register with MainDeployer
+ super.startService();
+ }
+
+ /**
+ * Implements the template method in superclass. This method stops all the
+ * applications in this server.
+ */
+ protected void stopService() throws Exception
+ {
+ // deregister with MainDeployer
+ super.stopService();
+ }
+
+ /**
+ * This method looks to the deployment for a META-INF/application-client.xml
+ * descriptor to identify a j2ee client jar.
+ *
+ * @param di The deployment info instance for the jar
+ * @return true if the deployment is a j2ee client jar, false otherwise
+ */
+ public boolean accepts(DeploymentInfo di)
+ {
+ // To be accepted the deployment's root name must end in jar
+ String urlStr = di.url.getFile();
+ if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".jar/"))
+ {
+ return false;
+ }
+
+ // However the jar must also contain an META-INF/application-client.xml
+ boolean accepts = false;
+ try
+ {
+ URL dd = di.localCl.findResource("META-INF/application-client.xml");
+ if (dd != null)
+ {
+ log.debug("Found a META-INF/application-client.xml file, di: " + di);
+ accepts = true;
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ return accepts;
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'create' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.CREATE_NOTIFICATION.
+ */
+ public void create(DeploymentInfo di) throws DeploymentException
+ {
+ super.create(di);
+ }
+
+ /**
+ * Parse the application-client.xml and jboss-client.xml descriptors.
+ *
+ * @param di the application client jar deployment info
+ */
+ public void start(DeploymentInfo di) throws DeploymentException
+ {
+ ClientMetaData metaData = null;
+ try
+ {
+ InputStream in = null;
+ if (di.alternativeDD == null)
+ {
+ in = di.localCl.getResourceAsStream("META-INF/application-client.xml");
+ }
+ else
+ {
+ String contentsDir = new File(di.url.getPath()).getParent();
+ in = new FileInputStream(contentsDir + "/" + di.alternativeDD);
+ }
+
+ if (in == null)
+ throw new DeploymentException("No META-INF/application-client.xml found");
+
+ metaData = null;
+ XmlFileLoader xfl = new XmlFileLoader(true);
+ Element appClient = xfl.getDocument(in, "META-INF/application-client.xml").getDocumentElement();
+ in.close();
+ metaData = new ClientMetaData();
+ metaData.setResourceClassLoader(di.localCl);
+ metaData.importClientXml(appClient);
+ di.metaData = metaData;
+
+ // Look for a jboss-client.xml descriptor
+ in = di.localCl.getResourceAsStream("META-INF/jboss-client.xml");
+ if (in != null)
+ {
+ xfl = new XmlFileLoader(true);
+ Element jbossClient = xfl.getDocument(in, "META-INF/jboss-client.xml").getDocumentElement();
+ in.close();
+ metaData.importJbossClientXml(jbossClient);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new DeploymentException("Failed to parse metadata", e);
+ }
+
+ try
+ {
+ setupEnvironment(di, metaData);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Failed to setup client ENC", e);
+ }
+
+ super.start(di);
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'stop' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.
+ */
+ public void stop(DeploymentInfo di) throws DeploymentException
+ {
+ // Teardown the JNDI context
+ ClientMetaData metaData = (ClientMetaData) di.metaData;
+ if (metaData != null)
+ {
+ String appClientName = metaData.getJndiName();
+ log.info("Removing client ENC from: " + appClientName);
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ Util.unbind(iniCtx, appClientName);
+ }
+ catch (NamingException e)
+ {
+ throw new DeploymentException("Failed to remove client ENC", e);
+ }
+ }
+ super.stop(di);
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'destroy' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION.
+ */
+ public void destroy(DeploymentInfo di) throws DeploymentException
+ {
+ super.destroy(di);
+ }
+
+ private void setupEnvironment(DeploymentInfo di, ClientMetaData metaData)
+ throws Exception
+ {
+ // Setup a JNDI context which contains
+ String appClientName = metaData.getJndiName();
+ InitialContext iniCtx = new InitialContext();
+ Context envCtx = Util.createSubcontext(iniCtx, appClientName);
+ log.debug("Creating client ENC binding under: " + appClientName);
+ // Bind environment properties
+ Iterator i = metaData.getEnvironmentEntries().iterator();
+ while (i.hasNext())
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData) i.next();
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+ entry.getType() + " to value:" + entry.getValue());
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+
+ // Bind EJB references
+ HashMap ejbRefs = metaData.getEjbReferences();
+ i = ejbRefs.values().iterator();
+ while (i.hasNext())
+ {
+ EjbRefMetaData ref = (EjbRefMetaData) i.next();
+ log.debug("Binding an EJBReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ String linkName = ref.getLink();
+ String jndiName = EjbUtil.findEjbLink(server, di, linkName);
+ log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName);
+ if (jndiName == null)
+ {
+ String msg = "Failed to resolve ejb-link: " + linkName
+ + " make by ejb-name: " + ref.getName();
+ throw new DeploymentException(msg);
+ }
+ log.debug("Link resolved to:" + jndiName);
+ Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
+ }
+ else
+ {
+ // Bind the bean level ejb-ref/jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or jndi-name in jboss.xml");
+ }
+ log.debug("Binding " + ref.getName() + " to : " + ref.getJndiName());
+ Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
+ }
+ }
+
+ // Bind service references
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+
+ // Bind resource references
+ HashMap resRefs = metaData.getResourceReferences();
+ i = resRefs.values().iterator();
+ while (i.hasNext())
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData) i.next();
+ String refName = ref.getRefName();
+ String jndiName = ref.getJndiName();
+
+ if (ref.getType().equals("java.net.URL"))
+ {
+ // URL bindings
+ 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);
+ }
+ }
+ else
+ {
+ // A resource link
+ log.debug("Binding resource: " + refName + " to JDNI as: " + jndiName);
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
+
+ // Bind resource env references
+ HashMap envRefs = metaData.getResourceEnvReferences();
+ i = envRefs.values().iterator();
+ while (i.hasNext())
+ {
+ ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData) i.next();
+ String encName = resRef.getRefName();
+ String jndiName = resRef.getJndiName();
+ // Should validate the type...
+ log.debug("Binding env resource: " + encName +
+ " to JDNI as: " + jndiName);
+ Util.bind(envCtx, encName, new LinkRef(jndiName));
+ }
+ log.info("Client ENC bound under: " + appClientName);
+ }
+}
+
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/ejb/Container.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/ejb/Container.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/ejb/Container.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1602 @@
+/*
+ * 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;
+
+// $Id: Container.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.rmi.MarshalException;
+import java.security.AccessController;
+import java.security.Policy;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBException;
+import javax.ejb.EJBObject;
+import javax.ejb.TimedObject;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.ejb.spi.HandleDelegate;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.transaction.TransactionManager;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.ejb.plugins.local.BaseLocalProxyFactory;
+import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.invocation.InvocationStatistics;
+import org.jboss.invocation.InvocationType;
+import org.jboss.invocation.JBossLazyUnmarshallingException;
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ApplicationMetaData;
+import org.jboss.metadata.BeanMetaData;
+import org.jboss.metadata.EjbLocalRefMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.MessageDestinationMetaData;
+import org.jboss.metadata.MessageDestinationRefMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.util.ObjectNameConverter;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.RealmMapping;
+import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.util.NestedError;
+import org.jboss.util.NestedRuntimeException;
+import org.jboss.util.naming.ENCThreadLocalKey;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.jboss.ws.integration.URLLoaderAdapter;
+import org.jboss.ws.integration.UnifiedVirtualFile;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.omg.CORBA.ORB;
+
+/**
+ * This is the base class for all EJB-containers in JBoss. A Container
+ * functions as the central hub of all metadata and plugins. Through this
+ * the container plugins can get hold of the other plugins and any metadata
+ * they need.
+ *
+ * <p>The EJBDeployer creates instances of subclasses of this class
+ * and calls the appropriate initialization methods.
+ *
+ * <p>A Container does not perform any significant work, but instead delegates
+ * to the plugins to provide for all kinds of algorithmic functionality.
+ *
+ * @see EJBDeployer
+ *
+ * @author <a href="mailto:rickard.oberg at jboss.org">Rickard �berg</a>
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ * @author <a href="bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:christoph.jung at infor.de">Christoph G. Jung</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 69712 $
+ *
+ * @jmx.mbean extends="org.jboss.system.ServiceMBean"
+ */
+public abstract class Container extends ServiceMBeanSupport
+ implements ContainerMBean, AllowedOperationsFlags
+{
+ public final static String BASE_EJB_CONTAINER_NAME =
+ "jboss.j2ee:service=EJB";
+
+ public final static ObjectName ORB_NAME = ObjectNameFactory.create("jboss:service=CorbaORB");
+
+ public final static ObjectName EJB_CONTAINER_QUERY_NAME =
+ ObjectNameFactory.create(BASE_EJB_CONTAINER_NAME + ",*");
+
+ protected static final Method EJBOBJECT_REMOVE;
+ /** A reference to {@link javax.ejb.TimedObject#ejbTimeout}. */
+ protected static final Method EJB_TIMEOUT;
+
+ /** This is the application that this container is a part of */
+ protected EjbModule ejbModule;
+
+ /**
+ * This is the local classloader of this container. Used for loading
+ * resources that must come from the local jar file for the container.
+ * NOT for loading classes!
+ */
+ protected ClassLoader localClassLoader;
+
+ /**
+ * This is the classloader of this container. All classes and resources that
+ * the bean uses will be loaded from here. By doing this we make the bean
+ * re-deployable
+ */
+ protected ClassLoader classLoader;
+
+ /** The class loader for remote dynamic classloading */
+ protected ClassLoader webClassLoader;
+
+ /**
+ * Externally supplied configuration data
+ */
+ private DeploymentInfo di;
+
+ /**
+ * This is the new metadata. it includes information from both ejb-jar and
+ * jboss.xml the metadata for the application can be accessed trough
+ * metaData.getApplicationMetaData()
+ */
+ protected BeanMetaData metaData;
+
+ /** This is the EnterpriseBean class */
+ protected Class beanClass;
+
+ /** This is the Home interface class */
+ protected Class homeInterface;
+
+ /** This is the Remote interface class */
+ protected Class remoteInterface;
+
+ /** The local home interface class */
+ protected Class localHomeInterface;
+
+ /** The local inteface class */
+ protected Class localInterface;
+
+ /** This is the TransactionManager */
+ protected TransactionManager tm;
+
+ /** This is the SecurityManager */
+ protected AuthenticationManager sm;
+
+ /** This is the realm mapping */
+ protected RealmMapping rm;
+
+ /** The custom security proxy used by the SecurityInterceptor */
+ protected Object securityProxy;
+
+ /** This is the bean lock manager that is to be used */
+ protected BeanLockManager lockManager;
+
+ /** ??? */
+ protected LocalProxyFactory localProxyFactory =
+ new BaseLocalProxyFactory();
+
+ /** This is a cache for method permissions */
+ private HashMap methodPermissionsCache = new HashMap();
+
+ /** Maps for MarshalledInvocation mapping */
+ protected Map marshalledInvocationMapping = new HashMap();
+
+ /** ObjectName of Container */
+ private ObjectName jmxName;
+ /** HashMap<String, EJBProxyFactory> for the invoker bindings */
+ protected HashMap proxyFactories = new HashMap();
+ /** A priviledged actions for MBeanServer.invoke when running with sec mgr */
+ private MBeanServerAction serverAction = new MBeanServerAction();
+
+ /**
+ * The Proxy factory is set in the Invocation. This TL is used
+ * for methods that do not have access to the Invocation.
+ */
+ protected ThreadLocal proxyFactoryTL = new ThreadLocal();
+
+ /** The number of create invocations that have been made */
+ protected long createCount;
+ /** The number of create invocations that have been made */
+ protected long removeCount;
+ /** Time statistics for the invoke(Invocation) methods */
+ protected InvocationStatistics invokeStats = new InvocationStatistics();
+
+ /** The JACC context id for the container */
+ protected String jaccContextID;
+
+ /**
+ * Flag to denote whether a JACC configuration has been fitted for authorization
+ */
+ protected boolean isJaccEnabled = false;
+
+ static
+ {
+ try
+ {
+ EJBOBJECT_REMOVE = EJBObject.class.getMethod("remove", new Class[0]);
+ EJB_TIMEOUT = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
+ }
+ catch (Throwable t)
+ {
+ throw new NestedRuntimeException(t);
+ }
+ }
+
+ // Public --------------------------------------------------------
+
+ public Class getLocalClass()
+ {
+ return localInterface;
+ }
+
+ public Class getLocalHomeClass()
+ {
+ return localHomeInterface;
+ }
+
+ public Class getRemoteClass()
+ {
+ return remoteInterface;
+ }
+
+ /**
+ * this actually should be called remotehome, but for interface compliance purposes
+ * we keep it like that
+ */
+ public Class getHomeClass()
+ {
+ return homeInterface;
+ }
+
+ /**
+ * Whether the bean is call by value
+ *
+ * @return true for call by value
+ */
+ public boolean isCallByValue()
+ {
+ if (ejbModule.isCallByValue())
+ return true;
+ return metaData.isCallByValue();
+ }
+
+ /**
+ * Sets a transaction manager for this container.
+ *
+ * @see javax.transaction.TransactionManager
+ *
+ * @param tm
+ */
+ public void setTransactionManager(final TransactionManager tm)
+ {
+ this.tm = tm;
+ }
+
+ /**
+ * Returns this container's transaction manager.
+ *
+ * @return A concrete instance of javax.transaction.TransactionManager
+ */
+ public TransactionManager getTransactionManager()
+ {
+ return tm;
+ }
+
+ public void setSecurityManager(AuthenticationManager sm)
+ {
+ this.sm = sm;
+ }
+
+ public AuthenticationManager getSecurityManager()
+ {
+ return sm;
+ }
+
+ public BeanLockManager getLockManager()
+ {
+ return lockManager;
+ }
+
+ public void setLockManager(final BeanLockManager lockManager)
+ {
+ this.lockManager = lockManager;
+ lockManager.setContainer(this);
+ }
+
+ public void addProxyFactory(String invokerBinding, EJBProxyFactory factory)
+ {
+ proxyFactories.put(invokerBinding, factory);
+ }
+
+ public void setRealmMapping(final RealmMapping rm)
+ {
+ this.rm = rm;
+ }
+
+ public RealmMapping getRealmMapping()
+ {
+ return rm;
+ }
+
+ public void setSecurityProxy(Object proxy)
+ {
+ this.securityProxy = proxy;
+ }
+
+ public Object getSecurityProxy()
+ {
+ return securityProxy;
+ }
+
+ public EJBProxyFactory getProxyFactory()
+ {
+ EJBProxyFactory factory = (EJBProxyFactory)proxyFactoryTL.get();
+ // There's no factory thread local which means this is probably
+ // a local invocation. Just use the first (usually only)
+ // proxy factory.
+ // TODO: define a default factory in the meta data or
+ // even better, let the return over the original transport
+ // plugin the transport layer for the generated proxy
+ if (factory == null && remoteInterface != null)
+ {
+ Iterator i = proxyFactories.values().iterator();
+ if (i.hasNext())
+ factory = (EJBProxyFactory)i.next();
+ }
+ return factory;
+ }
+
+ public void setProxyFactory(Object factory)
+ {
+ proxyFactoryTL.set(factory);
+ }
+
+ public EJBProxyFactory lookupProxyFactory(String binding)
+ {
+ return (EJBProxyFactory)proxyFactories.get(binding);
+ }
+
+ /**
+ * Gets the DeploymentInfo for this Container
+ *
+ * @return The DeploymentInfo for this Container
+ */
+ public final DeploymentInfo getDeploymentInfo()
+ {
+ return di;
+ }
+
+ /**
+ * Sets the DeploymentInfo of this Container
+ *
+ * @param di The new DeploymentInfo to be used
+ */
+ public final void setDeploymentInfo(DeploymentInfo di)
+ {
+ this.di = di;
+ }
+
+ /**
+ * Sets the application deployment unit for this container. All the bean
+ * containers within the same application unit share the same instance.
+ *
+ * @param app application for this container
+ */
+ public void setEjbModule(EjbModule app)
+ {
+ ejbModule = app;
+ }
+
+ public String getJaccContextID()
+ {
+ return jaccContextID;
+ }
+
+ public void setJaccContextID(String id)
+ {
+ jaccContextID = id;
+ }
+
+ /**
+ * Get the flag whether JACC is enabled
+ * @return
+ */
+ public boolean isJaccEnabled()
+ {
+ return isJaccEnabled;
+ }
+
+ /**
+ * Set the flag that JACC is enabled
+ *
+ * @param isJaccEnabled
+ */
+ public void setJaccEnabled(boolean isJaccEnabled)
+ {
+ this.isJaccEnabled = isJaccEnabled;
+ }
+
+ /**
+ * Gets the application deployment unit for this container. All the bean
+ * containers within the same application unit share the same instance.
+ * @jmx.managed-attribute
+ */
+ public EjbModule getEjbModule()
+ {
+ return ejbModule;
+ }
+
+ /**
+ * Gets the number of create invocations that have been made
+ * @jmx.managed-attribute
+ */
+ public long getCreateCount()
+ {
+ return createCount;
+ }
+
+ /**
+ * Gets the number of remove invocations that have been made
+ * @jmx.managed-attribute
+ */
+ public long getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ /** Gets the invocation statistics collection
+ * @jmx.managed-attribute
+ */
+ public InvocationStatistics getInvokeStats()
+ {
+ return invokeStats;
+ }
+
+ /**
+ * Sets the local class loader for this container.
+ * Used for loading resources from the local jar file for this container.
+ * NOT for loading classes!
+ *
+ * @param cl
+ */
+ public void setLocalClassLoader(ClassLoader cl)
+ {
+ this.localClassLoader = cl;
+ }
+
+ /**
+ * Returns the local classloader for this container.
+ *
+ * @return The local classloader for this container.
+ */
+ public ClassLoader getLocalClassLoader()
+ {
+ return localClassLoader;
+ }
+
+ /**
+ * Sets the class loader for this container. All the classes and resources
+ * used by the bean in this container will use this classloader.
+ *
+ * @param cl
+ */
+ public void setClassLoader(ClassLoader cl)
+ {
+ this.classLoader = cl;
+ }
+
+ /**
+ * Returns the classloader for this container.
+ *
+ * @return
+ */
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /** Get the class loader for dynamic class loading via http.
+ */
+ public ClassLoader getWebClassLoader()
+ {
+ return webClassLoader;
+ }
+
+ /** Set the class loader for dynamic class loading via http.
+ */
+ public void setWebClassLoader(final ClassLoader webClassLoader)
+ {
+ this.webClassLoader = webClassLoader;
+ }
+
+ /**
+ * Sets the meta data for this container. The meta data consists of the
+ * properties found in the XML descriptors.
+ *
+ * @param metaData
+ */
+ public void setBeanMetaData(final BeanMetaData metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ /** Get the components environment context
+ * @jmx.managed-attribute
+ * @return Environment Context
+ */
+ public Context getEnvContext() throws NamingException
+ {
+ ClassLoader ccl = SecurityActions.getContextClassLoader();
+ try
+ {
+ // The ENC is a map keyed on the class loader
+ SecurityActions.setContextClassLoader(classLoader);
+ return (Context)new InitialContext().lookup("java:comp/env");
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(ccl);
+ }
+ }
+
+ /**
+ * Returns the metadata of this container.
+ *
+ * @jmx.managed-attribute
+ * @return metaData;
+ */
+ public BeanMetaData getBeanMetaData()
+ {
+ return metaData;
+ }
+
+ /**
+ * Returns the permissions for a method. (a set of roles)
+ *
+ * @return assemblyDescriptor;
+ */
+ public Set getMethodPermissions(Method m, InvocationType iface)
+ {
+ Set permissions;
+
+ if (methodPermissionsCache.containsKey(m))
+ {
+ permissions = (Set) methodPermissionsCache.get(m);
+ }
+ else if( m.equals(EJB_TIMEOUT) )
+ {
+ // No role is required to access the ejbTimeout as this is
+ permissions = new HashSet();
+ permissions.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ methodPermissionsCache.put(m, permissions);
+ }
+ else
+ {
+ String name = m.getName();
+ Class[] sig = m.getParameterTypes();
+ permissions = getBeanMetaData().getMethodPermissions(name, sig, iface);
+ methodPermissionsCache.put(m, permissions);
+ }
+
+ return permissions;
+ }
+
+ /**
+ * Returns the bean class instance of this container.
+ *
+ * @return instance of the Enterprise bean class.
+ */
+ public Class getBeanClass()
+ {
+ return beanClass;
+ }
+
+ /**
+ * Returns a new instance of the bean class or a subclass of the bean class.
+ * This factory style method is speciffically used by a container to supply
+ * an implementation of the abstract accessors in EJB2.0, but could be
+ * usefull in other situations. This method should ALWAYS be used instead
+ * of getBeanClass().newInstance();
+ *
+ * @return the new instance
+ *
+ * @see java.lang.Class#newInstance
+ */
+ public Object createBeanClassInstance() throws Exception
+ {
+ return getBeanClass().newInstance();
+ }
+
+ /**
+ * Sets the codebase of this container.
+ *
+ * @param codebase a possibly empty, but non null String with
+ * a sequence of URLs separated by spaces
+ * /
+ public void setCodebase(final String codebase)
+ {
+ if (codebase != null)
+ this.codebase = codebase;
+ }
+ */
+ /**
+ * Gets the codebase of this container.
+ *
+ * @return this container's codebase String, a sequence of URLs
+ * separated by spaces
+ * /
+ public String getCodebase()
+ {
+ return codebase;
+ }
+ */
+ /** Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName]
+ where the [jndiName] is either the bean remote home JNDI binding, or
+ the local home JNDI binding if the bean has no remote interfaces.
+ */
+ public ObjectName getJmxName()
+ {
+ if (jmxName == null)
+ {
+ BeanMetaData beanMetaData = getBeanMetaData();
+ if (beanMetaData == null)
+ {
+ throw new IllegalStateException("Container metaData is null");
+ }
+
+ String jndiName = beanMetaData.getContainerObjectNameJndiName();
+ if (jndiName == null)
+ {
+ throw new IllegalStateException("Container jndiName is null");
+ }
+
+ // The name must be escaped since the jndiName may be arbitrary
+ String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName;
+ try
+ {
+ jmxName = ObjectNameConverter.convert(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage());
+ }
+ }
+ return jmxName;
+ }
+
+ /**
+ * Creates the single Timer Service for this container if not already created
+ *
+ * @param pKey Bean id
+ * @return Container Timer Service
+ * @throws IllegalStateException If the type of EJB is not allowed to use the
+ * timer service, or the bean class does not implement javax.ejb.TimedObject
+ *
+ * @see javax.ejb.EJBContext#getTimerService
+ *
+ * @jmx.managed-operation
+ **/
+ public TimerService getTimerService(Object pKey)
+ throws IllegalStateException
+ {
+ if (this instanceof StatefulSessionContainer)
+ throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService");
+
+ // Validate that the bean implements the TimedObject interface
+ Class beanClass = this.getBeanClass();
+ if( TimedObject.class.isAssignableFrom(beanClass) == false )
+ {
+ String msg = this.getBeanMetaData().getEjbName()
+ +" requested getTimerService but "+beanClass
+ +" does not implement javax.ejb.TimedObject";
+ throw new IllegalStateException(msg);
+ }
+
+ TimerService timerService = null;
+ try
+ {
+ EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
+ timerService = service.createTimerService(getJmxName(), pKey, this);
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Could not create timer service", e);
+ }
+ return timerService;
+ }
+
+ /**
+ * Removes Timer Service for this container
+ *
+ * @param pKey Bean id
+ * @throws IllegalStateException If the type of EJB is not allowed to use the timer service
+ *
+ * @jmx.managed-operation
+ **/
+ public void removeTimerService(Object pKey)
+ throws IllegalStateException
+ {
+ try
+ {
+ EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
+ if (pKey != null)
+ {
+ // entity bean->remove()
+ service.removeTimerService(getJmxName(), pKey);
+ }
+ else
+ {
+ // container stop, we choose whether active timers
+ // should be persisted (default), or not (legacy)
+ service.removeTimerService(getJmxName(), getBeanMetaData().getTimerPersistence());
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Could not remove timer service", e);
+ }
+ }
+
+ /**
+ * Restore any timers previously persisted for this container
+ */
+ protected void restoreTimers()
+ {
+ try
+ {
+ // pass to the ejb timer service the container ObjectName
+ server.invoke(
+ EJBTimerService.OBJECT_NAME,
+ "restoreTimers",
+ new Object[] { getServiceName(), getClassLoader() },
+ new String[] { "javax.management.ObjectName" , "java.lang.ClassLoader" } );
+ }
+ catch (Exception e)
+ {
+ log.warn("Could not restore ejb timers", e);
+ }
+ }
+
+ /**
+ * The EJBDeployer calls this method. The EJBDeployer has set
+ * all the plugins and interceptors that this bean requires and now proceeds
+ * to initialize the chain. The method looks for the standard classes in
+ * the URL, sets up the naming environment of the bean. The concrete
+ * container classes should override this method to introduce
+ * implementation specific initialization behaviour.
+ *
+ * @throws Exception if loading the bean class failed
+ * (ClassNotFoundException) or setting up "java:"
+ * naming environment failed (DeploymentException)
+ */
+ protected void createService() throws Exception
+ {
+ // Acquire classes from CL
+ beanClass = classLoader.loadClass(metaData.getEjbClass());
+
+ if (metaData.getLocalHome() != null)
+ localHomeInterface = classLoader.loadClass(metaData.getLocalHome());
+ if (metaData.getLocal() != null)
+ localInterface = classLoader.loadClass(metaData.getLocal());
+
+ localProxyFactory.setContainer(this);
+ localProxyFactory.create();
+ if (localHomeInterface != null)
+ ejbModule.addLocalHome(this, localProxyFactory.getEJBLocalHome());
+ ejbModule.createMissingPermissions(this, metaData);
+ // Allow the policy to incorporate the policy configs
+ Policy.getPolicy().refresh();
+ }
+
+ /**
+ * A default implementation of starting the container service.
+ * The container registers it's dynamic MBean interface in the JMX base.
+ *
+ * The concrete container classes should override this method to introduce
+ * implementation specific start behaviour.
+ *
+ * todo implement the service lifecycle methods in an xmbean interceptor so
+ * non lifecycle managed ops are blocked when mbean is not started.
+ *
+ * @throws Exception An exception that occured during start
+ */
+ protected void startService() throws Exception
+ {
+ // Setup "java:comp/env" namespace
+ setupEnvironment();
+
+ localProxyFactory.start();
+ }
+
+ /**
+ * A default implementation of stopping the container service (no-op). The
+ * concrete container classes should override this method to introduce
+ * implementation specific stop behaviour.
+ */
+ protected void stopService() throws Exception
+ {
+ localProxyFactory.stop();
+ removeTimerService(null);
+ teardownEnvironment();
+ }
+
+ /**
+ * A default implementation of destroying the container service (no-op).
+ * The concrete container classes should override this method to introduce
+ * implementation specific destroy behaviour.
+ */
+ protected void destroyService() throws Exception
+ {
+ localProxyFactory.destroy();
+ ejbModule.removeLocalHome(this);
+
+ beanClass = null;
+ homeInterface = null;
+ remoteInterface = null;
+ localHomeInterface = null;
+ localInterface = null;
+ methodPermissionsCache.clear();
+ // InvocationStatistics holds refs to Methods from
+ // application classes, so to avoid a classloader
+ // leak, lets not just resetStats() but also replace
+ // the object
+ invokeStats.resetStats(); // in case someone else has a ref
+ invokeStats = new InvocationStatistics();
+ marshalledInvocationMapping.clear();
+ }
+
+ /**
+ * This method is called when a method call comes
+ * in on the Home object. The Container forwards this call to the
+ * interceptor chain for further processing.
+ *
+ * @param mi the object holding all info about this invocation
+ * @return the result of the home invocation
+ *
+ * @throws Exception
+ */
+ public abstract Object internalInvokeHome(Invocation mi)
+ throws Exception;
+
+ /**
+ * This method is called when a method call comes
+ * in on an EJBObject. The Container forwards this call to the interceptor
+ * chain for further processing.
+ */
+ public abstract Object internalInvoke(Invocation mi)
+ throws Exception;
+
+ abstract Interceptor createContainerInterceptor();
+
+ public abstract void addInterceptor(Interceptor in);
+
+ /** The detached invoker operation.
+ *
+ * @jmx.managed-operation
+ *
+ * @param mi - the method invocation context
+ * @return the value of the ejb invocation
+ * @throws Exception on error
+ */
+ public Object invoke(Invocation mi)
+ throws Exception
+ {
+ ClassLoader callerClassLoader = SecurityActions.getContextClassLoader();
+ long start = System.currentTimeMillis();
+ Method m = null;
+
+ Object type = null;
+ String contextID = getJaccContextID();
+ try
+ {
+ // JBAS-3732 - Remove classloader.equals optimization
+ SecurityActions.setContextClassLoader(this.classLoader);
+
+ // Set the JACC context id
+ mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID);
+ contextID = SecurityActions.setContextID(contextID);
+ // Set the standard JACC policy context handler data is not a SEI msg
+ if (mi.getType() != InvocationType.SERVICE_ENDPOINT)
+ {
+ EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
+ }
+ else
+ {
+ SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE);
+ SOAPMsgPolicyContextHandler.setMessage(msg);
+ }
+ // Set custom JACC policy handlers
+ BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData());
+
+ // Check against home, remote, localHome, local, getHome,
+ // getRemote, getLocalHome, getLocal
+ type = mi.getType();
+
+ // stat gathering: concurrent calls
+ this.invokeStats.callIn();
+
+ if (type == InvocationType.REMOTE ||
+ type == InvocationType.LOCAL ||
+ // web service calls come in as "ordinary" application invocations
+ type == InvocationType.SERVICE_ENDPOINT)
+ {
+ if (mi instanceof MarshalledInvocation)
+ {
+ ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("METHOD REMOTE INVOKE " +
+ mi.getObjectName() + "||" +
+ mi.getMethod().getName() + "||");
+ }
+ }
+
+ m = mi.getMethod();
+
+ Object obj = internalInvoke(mi);
+ return obj;
+ }
+ else if (type == InvocationType.HOME ||
+ type == InvocationType.LOCALHOME)
+ {
+ if (mi instanceof MarshalledInvocation)
+ {
+
+ ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("METHOD HOME INVOKE " +
+ mi.getObjectName() + "||" +
+ mi.getMethod().getName() + "||" +
+ mi.getArguments().toString());
+ }
+ }
+ m = mi.getMethod();
+
+ Object obj = internalInvokeHome(mi);
+ return obj;
+ }
+ else
+ {
+ throw new MBeanException(new IllegalArgumentException(
+ "Unknown invocation type: " + type));
+ }
+ }
+ /**
+ * Having to catch this exception here in case can not
+ * unmarshall arguments, values, etc. Then, convert to
+ * UnmarshalException as defined by spec (JBAS-2999)
+ */
+ catch (JBossLazyUnmarshallingException e)
+ {
+ InvocationType calltype = mi.getType();
+ boolean isLocal =
+ calltype == InvocationType.LOCAL ||
+ calltype == InvocationType.LOCALHOME;
+
+ // handle unmarshalling exception which should only come if problem unmarshalling
+ // invocation payload, arguments, or value on remote end.
+ if (isLocal)
+ {
+ throw new EJBException("UnmarshalException", e);
+ }
+ else
+ {
+ throw new MarshalException("MarshalException", e);
+ }
+ }
+ finally
+ {
+ if (m != null)
+ {
+ long end = System.currentTimeMillis();
+ long elapsed = end - start;
+ this.invokeStats.updateStats(m, elapsed);
+ }
+
+ // stat gathering: concurrent calls
+ this.invokeStats.callOut();
+
+ // Restore the incoming class loader
+ SecurityActions.setContextClassLoader(callerClassLoader);
+
+ // Restore the incoming context id
+ contextID = SecurityActions.setContextID(contextID);
+
+ if (mi.getType() == InvocationType.SERVICE_ENDPOINT)
+ {
+ // Remove msg from ThreadLocal to prevent leakage into the thread pool
+ SOAPMsgPolicyContextHandler.setMessage(null);
+ }
+ else
+ {
+ // Remove args from ThreadLocal to prevent leakage into the thread pool
+ EJBArgsPolicyContextHandler.setArgs(null);
+ }
+
+ // Remove metadata from ThreadLocal to prevent leakage into the thread pool
+ BeanMetaDataPolicyContextHandler.setMetaData(null);
+ }
+ }
+
+ // Private -------------------------------------------------------
+
+ /**
+ * This method sets up the naming environment of the bean.
+ * We create the java:comp/env namespace with properties, EJB-References,
+ * and DataSource ressources.
+ */
+ private void setupEnvironment() throws Exception
+ {
+ BeanMetaData beanMetaData = getBeanMetaData();
+ // debug
+ log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName());
+ ClassLoader tcl = SecurityActions.getContextClassLoader();
+ log.debug("TCL: " + tcl);
+
+ ORB orb = null;
+ HandleDelegate hd = null;
+ try
+ {
+ orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
+ hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate");
+ }
+ catch (Throwable t)
+ {
+ log.debug("Unable to retrieve orb" + t.toString());
+ }
+
+ // Since the BCL is already associated with this thread we can start
+ // using the java: namespace directly
+ Context ctx = (Context)new InitialContext().lookup("java:comp");
+
+ // Bind the orb
+ if (orb != null)
+ {
+ NonSerializableFactory.rebind(ctx, "ORB", orb);
+ log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
+
+ NonSerializableFactory.rebind(ctx, "HandleDelegate", hd);
+ log.debug("Bound java:comp:/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
+ }
+
+ Context envCtx = ctx.createSubcontext("env");
+
+ // Bind environment properties
+ {
+ Iterator i = beanMetaData.getEnvironmentEntries();
+ while (i.hasNext())
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData)i.next();
+
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+ entry.getType() + " to value:" + entry.getValue());
+
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+ }
+
+ // Bind EJB references
+ {
+ Iterator i = beanMetaData.getEjbReferences();
+ while (i.hasNext())
+ {
+ EjbRefMetaData ref = (EjbRefMetaData)i.next();
+ log.debug("Binding an EJBReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ String linkName = ref.getLink();
+ String jndiName = EjbUtil.findEjbLink(server, di, linkName);
+
+ log.debug("Binding " + ref.getName() +
+ " to ejb-link: " + linkName + " -> " + jndiName);
+
+ if (jndiName == null)
+ {
+ String msg = "Failed to resolve ejb-link: " + linkName
+ + " make by ejb-name: " + ref.getName();
+ throw new DeploymentException(msg);
+ }
+
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(jndiName));
+
+ }
+ else
+ {
+ // Get the invoker specific ejb-ref mappings
+ Iterator it = beanMetaData.getInvokerBindings();
+ Reference reference = null;
+ while (it.hasNext())
+ {
+ String invokerBinding = (String)it.next();
+ // Check for an invoker level jndi-name
+ String name = ref.getInvokerBinding(invokerBinding);
+ // Check for an global jndi-name
+ if (name == null)
+ name = ref.getJndiName();
+ if (name == null)
+ {
+ throw new DeploymentException
+ ("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml or " +
+ "jndi-name in jboss.xml");
+ }
+
+ StringRefAddr addr = new StringRefAddr(invokerBinding, name);
+ log.debug("adding " + invokerBinding + ":" + name +
+ " to Reference");
+
+ if (reference == null)
+ {
+ reference = new Reference("javax.naming.LinkRef",
+ ENCThreadLocalKey.class.getName(),
+ null);
+ }
+ reference.add(addr);
+ }
+
+ // If there were invoker bindings create bind the reference
+ if (reference != null)
+ {
+ if (ref.getJndiName() != null)
+ {
+ // Add default for the bean level ejb-ref/jndi-name
+ StringRefAddr addr =
+ new StringRefAddr("default", ref.getJndiName());
+ reference.add(addr);
+ }
+ if (reference.size() == 1 && reference.get("default") == null)
+ {
+ /* There is only one invoker binding and its not default so
+ create a default binding to allow the link to have a value
+ when accessed without an invoker active.
+ */
+ StringRefAddr addr = (StringRefAddr)reference.get(0);
+ String target = (String)addr.getContent();
+ StringRefAddr addr1 = new StringRefAddr("default", target);
+ reference.add(addr1);
+ }
+ Util.bind(envCtx, ref.getName(), reference);
+ }
+ else
+ {
+ // Bind the bean level ejb-ref/jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or jndi-name in jboss.xml");
+ }
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(ref.getJndiName()));
+ }
+ }
+ }
+ }
+
+ // Bind Local EJB references
+ {
+ Iterator i = beanMetaData.getEjbLocalReferences();
+ while (i.hasNext())
+ {
+ EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
+ String refName = ref.getName();
+ log.debug("Binding an EJBLocalReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ log.debug("Binding " + refName + " to bean source: " + ref.getLink());
+
+ String jndiName = EjbUtil.findLocalEjbLink(server, di,
+ ref.getLink());
+
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(jndiName));
+ }
+ else
+ {
+ // Bind the bean level ejb-local-ref/local-jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or local-jndi-name in jboss.xml");
+ }
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(ref.getJndiName()));
+ }
+ }
+ }
+
+ // Bind service references
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+
+ // Bind resource references
+ {
+ Iterator i = beanMetaData.getResourceReferences();
+
+ // let's play guess the cast game ;) New metadata should fix this.
+ ApplicationMetaData application =
+ beanMetaData.getApplicationMetaData();
+
+ while (i.hasNext())
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData)i.next();
+
+ String resourceName = ref.getResourceName();
+ String finalName = application.getResourceByName(resourceName);
+ String resType = ref.getType();
+ // If there was no resource-manager specified then an immeadiate
+ // jndi-name or res-url name should have been given
+ if (finalName == null)
+ finalName = ref.getJndiName();
+
+ if (finalName == null && resType.equals("java.net.URL") == false)
+ {
+ // the application assembler did not provide a resource manager
+ // if the type is javax.sql.Datasoure use the default one
+
+ if (ref.getType().equals("javax.sql.DataSource"))
+ {
+ // Go through JNDI and look for DataSource - use the first one
+ Context dsCtx = new InitialContext();
+ try
+ {
+ // Check if it is available in JNDI
+ dsCtx.lookup("java:/DefaultDS");
+ finalName = "java:/DefaultDS";
+ }
+ catch (Exception e)
+ {
+ log.debug("failed to lookup DefaultDS; ignoring", e);
+ }
+ finally
+ {
+ dsCtx.close();
+ }
+ }
+
+ // Default failed? Warn user and move on
+ // POTENTIALLY DANGEROUS: should this be a critical error?
+ if (finalName == null)
+ {
+ log.warn("No resource manager found for " +
+ ref.getResourceName());
+ continue;
+ }
+ }
+
+ if (resType.equals("java.net.URL"))
+ {
+ // URL bindings
+ if (ref.getResURL() != null)
+ {
+ // The URL string was given by the res-url
+ log.debug("Binding URL: " + ref.getRefName() +
+ " to JDNI ENC as: " + ref.getResURL());
+ URL resURL = new URL(ref.getResURL());
+ Util.bind(envCtx, ref.getRefName(), resURL);
+ }
+ else
+ {
+ log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
+ Object bind = null;
+ if (ref.getJndiName() != null)
+ {
+ // Was the url given as a jndi-name reference to link to it
+ bind = new LinkRef(finalName);
+ }
+ else
+ {
+ // The url string was given via a resource-name mapping
+ bind = new URL(finalName);
+ }
+ Util.bind(envCtx, ref.getRefName(), bind);
+ }
+ }
+ else
+ {
+ // Resource Manager bindings, should validate the type...
+ log.debug("Binding resource manager: " + ref.getRefName() +
+ " to JDNI ENC as: " + finalName);
+
+ Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
+ }
+ }
+ }
+
+ // Bind resource env references
+ {
+ Iterator i = beanMetaData.getResourceEnvReferences();
+ while (i.hasNext())
+ {
+ ResourceEnvRefMetaData resRef =
+ (ResourceEnvRefMetaData)i.next();
+ String encName = resRef.getRefName();
+ String jndiName = resRef.getJndiName();
+ // Should validate the type...
+ log.debug("Binding env resource: " + encName +
+ " to JDNI ENC as: " + jndiName);
+
+ Util.bind(envCtx, encName, new LinkRef(jndiName));
+ }
+ }
+
+ // Bind message destination references
+ {
+ Iterator i = beanMetaData.getMessageDestinationReferences();
+
+ while (i.hasNext())
+ {
+ MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();
+
+ String refName = ref.getRefName();
+ String jndiName = ref.getJNDIName();
+ String link = ref.getLink();
+ if (link != null)
+ {
+ if (jndiName == null)
+ {
+ MessageDestinationMetaData messageDestination = getMessageDestination(link);
+ if (messageDestination == null)
+ throw new DeploymentException("message-destination-ref '" + refName +
+ "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml");
+ else
+ {
+ String linkJNDIName = messageDestination.getJNDIName();
+ if (linkJNDIName == null)
+ log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml");
+ else
+ jndiName = linkJNDIName;
+ }
+ }
+ else
+ log.warn("message-destination-ref '" + refName +
+ "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml");
+ }
+ else if (jndiName == null)
+ throw new DeploymentException("message-destination-ref '" + refName +
+ "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml");
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
+
+ // Create a java:comp/env/security/security-domain link to the container
+ // or application security-domain if one exists so that access to the
+ // security manager can be made without knowing the global jndi name.
+
+ String securityDomain =
+ metaData.getContainerConfiguration().getSecurityDomain();
+ if (securityDomain == null)
+ securityDomain = metaData.getApplicationMetaData().getSecurityDomain();
+ if (securityDomain != null)
+ {
+ log.debug("Binding securityDomain: " + securityDomain +
+ " to JDNI ENC as: security/security-domain");
+
+ Util.bind(envCtx,
+ "security/security-domain",
+ new LinkRef(securityDomain));
+ Util.bind(envCtx,
+ "security/subject",
+ new LinkRef(securityDomain + "/subject"));
+ }
+
+ log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName());
+ }
+
+ public MessageDestinationMetaData getMessageDestination(String link)
+ {
+ return EjbUtil.findMessageDestination(server, di, link);
+ }
+
+ /**
+ *The <code>teardownEnvironment</code> method unbinds everything from
+ * the comp/env context. It would be better do destroy the env context
+ * but destroyContext is not currently implemented..
+ *
+ * @exception Exception if an error occurs
+ */
+ private void teardownEnvironment() throws Exception
+ {
+ Context ctx = (Context)new InitialContext().lookup("java:comp");
+ ctx.unbind("env");
+ log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName());
+ try
+ {
+ NonSerializableFactory.unbind("ORB");
+ log.debug("Unbound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
+
+ NonSerializableFactory.unbind("HandleDelegate");
+ log.debug("Unbound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
+ }
+ catch (NamingException ignored)
+ {
+ }
+ }
+
+ /**
+ * The base class for container interceptors.
+ *
+ * <p>
+ * All container interceptors perform the same basic functionality
+ * and only differ slightly.
+ */
+ protected abstract class AbstractContainerInterceptor
+ implements Interceptor
+ {
+ protected final Logger log = Logger.getLogger(this.getClass());
+
+ public void setContainer(Container con)
+ {
+ }
+
+ public void setNext(Interceptor interceptor)
+ {
+ }
+
+ public Interceptor getNext()
+ {
+ return null;
+ }
+
+ public void create()
+ {
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ protected void rethrow(Exception e)
+ throws Exception
+ {
+ if (e instanceof IllegalAccessException)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ }
+ else if (e instanceof InvocationTargetException)
+ {
+ Throwable t = ((InvocationTargetException)e).getTargetException();
+
+ if (t instanceof EJBException)
+ {
+ throw (EJBException)t;
+ }
+ else if (t instanceof Exception)
+ {
+ throw (Exception)t;
+ }
+ else if (t instanceof Error)
+ {
+ throw (Error)t;
+ }
+ else
+ {
+ throw new NestedError("Unexpected Throwable", t);
+ }
+ }
+
+ throw e;
+ }
+
+ // Monitorable implementation ------------------------------------
+
+ public void sample(Object s)
+ {
+ // Just here to because Monitorable request it but will be removed soon
+ }
+
+ public Map retrieveStatistic()
+ {
+ return null;
+ }
+
+ public void resetStatistic()
+ {
+ }
+ }
+
+ /** Perform the MBeanServer.invoke op in a PrivilegedExceptionAction if
+ * running with a security manager.
+ */
+ class MBeanServerAction implements PrivilegedExceptionAction
+ {
+ private ObjectName target;
+ String method;
+ Object[] args;
+ String[] sig;
+
+ MBeanServerAction()
+ {
+ }
+
+ MBeanServerAction(ObjectName target, String method, Object[] args, String[] sig)
+ {
+ this.target = target;
+ this.method = method;
+ this.args = args;
+ this.sig = sig;
+ }
+
+ public Object run() throws Exception
+ {
+ Object rtnValue = server.invoke(target, method, args, sig);
+ return rtnValue;
+ }
+
+ Object invoke(ObjectName target, String method, Object[] args, String[] sig)
+ throws Exception
+ {
+ SecurityManager sm = System.getSecurityManager();
+ Object rtnValue = null;
+ if (sm == null)
+ {
+ // Direct invocation on MBeanServer
+ rtnValue = server.invoke(target, method, args, sig);
+ }
+ else
+ {
+ try
+ {
+ // Encapsulate the invocation in a PrivilegedExceptionAction
+ MBeanServerAction action = new MBeanServerAction(target, method, args, sig);
+ rtnValue = AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ throw ex;
+ }
+ }
+ return rtnValue;
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/BeanMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/BeanMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/BeanMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1108 @@
+/*
+ * 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.metadata;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.invocation.InvocationType;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.NobodyPrincipal;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+
+/**
+ * A common meta data class for the entity, message-driven and session beans.
+ *
+ * @author <a href="mailto:sebastien.alborini at m4x.org">Sebastien Alborini</a>
+ * @author <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author <a href="mailto:docodan at mvcsoft.com">Daniel OConnor</a>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:criege at riege.com">Christian Riege</a>
+ * @author <a href="mailto:Thomas.Diesler at jboss.org">Thomas Diesler</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ *
+ * @version $Revision: 69712 $
+ */
+public abstract class BeanMetaData
+ extends MetaData
+{
+ // Constants -----------------------------------------------------
+
+ public static final char SESSION_TYPE = 'S';
+ public static final char ENTITY_TYPE = 'E';
+ public static final char MDB_TYPE = 'M';
+ public static final String LOCAL_INVOKER_PROXY_BINDING = "LOCAL";
+
+ // Attributes ----------------------------------------------------
+ /** The metadata from the toplevel ejb-jar.xml/jboss.xml elements */
+ private ApplicationMetaData application;
+
+ // from ejb-jar.xml
+ /** The ejb-name element specifies an enterprise bean's name. This name is
+ assigned by the ejb-jar file producer to name the enterprise bean in
+ the ejb-jar file's deployment descriptor. The name must be unique
+ among the names of the enterprise beans in the same ejb-jar file.
+ */
+ private String ejbName;
+ /** The home element contains the fully-qualified name of the enterprise
+ bean's home interface. */
+ private String homeClass;
+ /** The remote element contains the fully-qualified name of the enterprise
+ bean's remote interface. */
+ private String remoteClass;
+ /** The local-home element contains the fully-qualified name of the
+ enterprise bean's local home interface. */
+ private String localHomeClass;
+ /** The local element contains the fully-qualified name of the enterprise
+ bean's local interface */
+ private String localClass;
+ /** The service-endpoint element contains the fully-qualified
+ * name of the bean�s service endpoint interface (SEI) */
+ protected String serviceEndpointClass;
+ /** The ejb-class element contains the fully-qualified name of the
+ enterprise bean's class. */
+ private String ejbClass;
+ /** The type of bean: ENTITY_TYPE, SESSION_TYPE, MDB_TYPE */
+ protected char beanType;
+ /** Is this bean's transactions managed by the container? */
+ protected boolean containerManagedTx = true;
+
+ /** The The env-entry element(s) contains the declaration of an enterprise
+ bean's environment entry */
+ private ArrayList environmentEntries = new ArrayList();
+ /** The The ejb-ref element(s) for the declaration of a reference to an
+ enterprise bean's home */
+ private HashMap ejbReferences = new HashMap();
+ /** The ejb-local-ref element(s) info */
+ private HashMap ejbLocalReferences = new HashMap();
+ /** The HashMap<ServiceRefMetaData> service-ref element(s) info */
+ private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
+ /** The security-role-ref element(s) info */
+ private ArrayList securityRoleReferences = new ArrayList();
+ /** The security-idemtity element info */
+ private SecurityIdentityMetaData securityIdentity = null;
+ /** */
+ private SecurityIdentityMetaData ejbTimeoutIdentity = null;
+ /** The resource-ref element(s) info */
+ private HashMap resourceReferences = new HashMap();
+ /** The resource-env-ref element(s) info */
+ private HashMap resourceEnvReferences = new HashMap();
+ /** The message destination references */
+ private HashMap messageDestinationReferences = new HashMap();
+ /** The method attributes */
+ private ArrayList methodAttributes = new ArrayList();
+ private ConcurrentReaderHashMap cachedMethodAttributes = new ConcurrentReaderHashMap();
+ /** The assembly-descriptor/method-permission element(s) info */
+ private ArrayList permissionMethods = new ArrayList();
+ /** The assembly-descriptor/container-transaction element(s) info */
+ private ArrayList transactionMethods = new ArrayList();
+ /** A cache mapping methods to transaction attributes. */
+ private ConcurrentReaderHashMap methodTx = new ConcurrentReaderHashMap();
+ /** The assembly-descriptor/exclude-list method(s) */
+ private ArrayList excludedMethods = new ArrayList();
+ /** The invoker names to JNDI name mapping */
+ protected HashMap invokerBindings = null;
+ /** The cluster-config element info */
+ private ClusterConfigMetaData clusterConfig = null;
+
+ /** The JNDI name under with the home interface should be bound */
+ private String jndiName;
+
+ /** The JNDI name under with the local home interface should be bound */
+ private String localJndiName;
+ /** The container configuration name */
+ protected String configurationName;
+ /** The container configuration metadata */
+ private ConfigurationMetaData configuration;
+ /** The custom security proxy class */
+ private String securityProxy;
+
+ /** Is the bean marked as clustered */
+ protected boolean clustered = false;
+ /** Should the bean use by value call semeantics */
+ protected boolean callByValue = false;
+ /** Any object names for services the bean depends on */
+ private Collection depends = new LinkedList();
+
+ /** Describes the security configuration information for the IOR. Optional element. Since 4.0. */
+ private IorSecurityConfigMetaData iorSecurityConfig;
+ /** The jboss port-component binding for a ejb webservice */
+ protected EjbPortComponentMetaData portComponent;
+ /** Whether to throw an exception on a rollback if there is no exception */
+ private boolean exceptionRollback = false;
+ /** Whether timer persistence is enabled */
+ private boolean timerPersistence = true;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public BeanMetaData(ApplicationMetaData app, char beanType)
+ {
+ this.application = app;
+ this.beanType = beanType;
+ }
+
+ public boolean isSession()
+ {
+ return beanType == SESSION_TYPE;
+ }
+
+ public boolean isMessageDriven()
+ {
+ return beanType == MDB_TYPE;
+ }
+
+ public boolean isEntity()
+ {
+ return beanType == ENTITY_TYPE;
+ }
+
+ public String getHome()
+ {
+ return homeClass;
+ }
+
+ public String getRemote()
+ {
+ return remoteClass;
+ }
+
+ public String getLocalHome()
+ {
+ return localHomeClass;
+ }
+
+ public String getLocal()
+ {
+ return localClass;
+ }
+
+ public String getServiceEndpoint()
+ {
+ return serviceEndpointClass;
+ }
+
+ public EjbPortComponentMetaData getPortComponent()
+ {
+ return portComponent;
+ }
+
+ public String getEjbClass()
+ {
+ return ejbClass;
+ }
+
+ public String getEjbName()
+ {
+ return ejbName;
+ }
+
+ public boolean isContainerManagedTx()
+ {
+ return containerManagedTx;
+ }
+
+ public boolean isBeanManagedTx()
+ {
+ return !containerManagedTx;
+ }
+
+ public Iterator getEjbReferences()
+ {
+ return ejbReferences.values().iterator();
+ }
+
+ public Iterator getEjbLocalReferences()
+ {
+ return ejbLocalReferences.values().iterator();
+ }
+
+ protected abstract void defaultInvokerBindings();
+
+ public Iterator getInvokerBindings()
+ {
+ if (invokerBindings == null)
+ {
+ // See if there is a container default invoker name
+ String[] defaultNames = configuration.getInvokers();
+ if (defaultNames.length > 0)
+ {
+ invokerBindings = new HashMap();
+ for (int count = 0; count < defaultNames.length; count++)
+ {
+ invokerBindings.put(defaultNames[count], getJndiName());
+ }
+ }
+ else
+ {
+ // Use the hard-coded defaults
+ defaultInvokerBindings();
+ }
+ }
+
+ return invokerBindings.keySet().iterator();
+ }
+
+ public String getInvokerBinding(String invokerName)
+ {
+ if (invokerBindings == null)
+ {
+ defaultInvokerBindings();
+ }
+
+ return (String)invokerBindings.get(invokerName);
+ }
+
+ public EjbRefMetaData getEjbRefByName(String name)
+ {
+ return (EjbRefMetaData)ejbReferences.get(name);
+ }
+
+ public EjbLocalRefMetaData getEjbLocalRefByName(String name)
+ {
+ return (EjbLocalRefMetaData)ejbLocalReferences.get(name);
+ }
+
+ public Iterator getEnvironmentEntries()
+ {
+ return environmentEntries.iterator();
+ }
+
+ public Iterator getSecurityRoleReferences()
+ {
+ return securityRoleReferences.iterator();
+ }
+
+ public Iterator getResourceReferences()
+ {
+ return resourceReferences.values().iterator();
+ }
+
+ public Iterator getResourceEnvReferences()
+ {
+ return resourceEnvReferences.values().iterator();
+ }
+
+ public Iterator getMessageDestinationReferences()
+ {
+ return messageDestinationReferences.values().iterator();
+ }
+
+ /**
+ * @return HashMap<ServiceRefMetaData>
+ */
+ public HashMap<String, ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public String getJndiName()
+ {
+ // jndiName may be set in jboss.xml
+ if (jndiName == null)
+ {
+ jndiName = ejbName;
+ }
+ return jndiName;
+ }
+
+ /**
+ * Gets the JNDI name under with the local home interface should be bound.
+ * The default is local/<ejbName>
+ */
+ public String getLocalJndiName()
+ {
+ if (localJndiName == null)
+ {
+ // Generate a unique name based on ejbName + identityHashCode
+ localJndiName = "local/" + ejbName + '@' + System.identityHashCode(ejbName);
+ }
+ return localJndiName;
+ }
+
+ /**
+ * Gets the container jndi name used in the object name
+ */
+ public String getContainerObjectNameJndiName()
+ {
+ return getHome() != null ? getJndiName() : getLocalJndiName();
+ }
+
+ public String getConfigurationName()
+ {
+ if (configurationName == null)
+ {
+ configurationName = getDefaultConfigurationName();
+ }
+ return configurationName;
+ }
+
+ public ConfigurationMetaData getContainerConfiguration()
+ {
+ if (configuration == null)
+ {
+ String configName = getConfigurationName();
+ configuration = application.getConfigurationMetaDataByName(configName);
+ if (configuration == null)
+ throw new IllegalStateException("Container config not found " + configName);
+ }
+ return configuration;
+ }
+
+ public String getSecurityProxy()
+ {
+ return securityProxy;
+ }
+
+ public SecurityIdentityMetaData getSecurityIdentityMetaData()
+ {
+ return securityIdentity;
+ }
+ public SecurityIdentityMetaData getEjbTimeoutIdentity()
+ {
+ return ejbTimeoutIdentity;
+ }
+
+ public ApplicationMetaData getApplicationMetaData()
+ {
+ return application;
+ }
+
+ public abstract String getDefaultConfigurationName();
+
+ public Iterator getTransactionMethods()
+ {
+ return transactionMethods.iterator();
+ }
+
+ public Iterator getPermissionMethods()
+ {
+ return permissionMethods.iterator();
+ }
+
+ public Iterator getExcludedMethods()
+ {
+ return excludedMethods.iterator();
+ }
+
+ public void addTransactionMethod(MethodMetaData method)
+ {
+ transactionMethods.add(method);
+ }
+
+ public void addPermissionMethod(MethodMetaData method)
+ {
+ // Insert unchecked methods into the front of the list to speed
+ // up their validation
+ if (method.isUnchecked())
+ {
+ permissionMethods.add(0, method);
+ }
+ else
+ {
+ permissionMethods.add(method);
+ }
+ }
+
+ public void addExcludedMethod(MethodMetaData method)
+ {
+ excludedMethods.add(method);
+ }
+
+ public byte getMethodTransactionType(String methodName, Class[] params, InvocationType iface)
+ {
+ // default value
+ byte result = TX_UNKNOWN;
+
+ MethodMetaData bestMatch = null;
+ Iterator iterator = getTransactionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+
+ // this is the first match
+ if (bestMatch == null)
+ {
+ bestMatch = m;
+ }
+ else
+ {
+ // this is a better match because the name is more precise
+ if (bestMatch.getMethodName().equals("*"))
+ {
+ bestMatch = m;
+ }
+ // this is a better match because now we have parameters, we cant get any better
+ if (m.getMethodParams().length > 0)
+ {
+ bestMatch = m;
+ break;
+ }
+ }
+ }
+ }
+
+ if (bestMatch != null)
+ {
+ result = bestMatch.getTransactionType();
+ }
+
+ return result;
+ }
+
+ // This should be cached, since this method is called very often
+ public byte getTransactionMethod(Method m, InvocationType iface)
+ {
+ if (m == null)
+ return MetaData.TX_SUPPORTS;
+
+ Byte b = (Byte)methodTx.get(m);
+ if (b != null) return b.byteValue();
+
+ byte result = getMethodTransactionType(m.getName(), m.getParameterTypes(), iface);
+
+ // provide default if method is not found in descriptor
+ if (result == MetaData.TX_UNKNOWN)
+ result = MetaData.TX_REQUIRED;
+
+ methodTx.put(m, new Byte(result));
+ return result;
+ }
+
+ public Collection getDepends()
+ {
+ Collection allDepends = new LinkedList(depends);
+ allDepends.addAll(getContainerConfiguration().getDepends());
+ return allDepends;
+ }
+
+ /**
+ * Checks meta data to obtain the Method Attributes of a bean's method:
+ * method attributes are read-only, idempotent and potentially other
+ * ones as well.
+ * These jboss-specific method attributes are described in jboss.xml
+ */
+ private MethodAttributes methodAttributesForMethod(String methodName)
+ {
+ if (methodName == null)
+ methodName = "*null*";
+
+ MethodAttributes ma =
+ (MethodAttributes)cachedMethodAttributes.get(methodName);
+
+ if (ma == null)
+ {
+ Iterator iterator = methodAttributes.iterator();
+ while (iterator.hasNext() && ma == null)
+ {
+ ma = (MethodAttributes)iterator.next();
+ if (!ma.patternMatches(methodName))
+ {
+ ma = null;
+ }
+ }
+ if (ma == null)
+ {
+ ma = MethodAttributes.kDefaultMethodAttributes;
+ }
+
+ cachedMethodAttributes.put(methodName, ma);
+ }
+ return ma;
+ }
+
+ /**
+ * Is this method a read-only method described in jboss.xml?
+ */
+ public boolean isMethodReadOnly(String methodName)
+ {
+ return methodAttributesForMethod(methodName).readOnly;
+ }
+
+ public boolean isMethodReadOnly(Method method)
+ {
+ if (method == null)
+ {
+ return false;
+ }
+ return methodAttributesForMethod(method.getName()).readOnly;
+ }
+
+ /**
+ * Get the transaction timeout for the method
+ */
+ public int getTransactionTimeout(String methodName)
+ {
+ return methodAttributesForMethod(methodName).txTimeout;
+ }
+
+ public int getTransactionTimeout(Method method)
+ {
+ if (method == null)
+ return 0;
+ return getTransactionTimeout(method.getName());
+ }
+
+ /**
+ * A somewhat tedious method that builds a Set<Principal> of the roles
+ * that have been assigned permission to execute the indicated method. The
+ * work performed is tedious because of the wildcard style of declaring
+ * method permission allowed in the ejb-jar.xml descriptor. This method is
+ * called by the Container.getMethodPermissions() when it fails to find the
+ * prebuilt set of method roles in its cache.
+ *
+ * @return The Set<Principal> for the application domain roles that
+ * caller principal's are to be validated against.
+ */
+ public Set getMethodPermissions(String methodName, Class[] params,
+ InvocationType iface)
+ {
+ Set result = new HashSet();
+ // First check the excluded method list as this takes priority over
+ // all other assignments
+ Iterator iterator = getExcludedMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ /* No one is allowed to execute this method so add a role that
+ fails to equate to any Principal or Principal name and return.
+ We don't return null to differentiate between an explicit
+ assignment of no access and no assignment information.
+ */
+ result.add(NobodyPrincipal.NOBODY_PRINCIPAL);
+ return result;
+ }
+ }
+
+ // Check the permissioned methods list
+ iterator = getPermissionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ /* If this is an unchecked method anyone can access it so
+ set the result set to a role that equates to any Principal or
+ Principal name and return.
+ */
+ if (m.isUnchecked())
+ {
+ result.clear();
+ result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ break;
+ }
+ // Else, add all roles
+ else
+ {
+ Iterator rolesIterator = m.getRoles().iterator();
+ while (rolesIterator.hasNext())
+ {
+ String roleName = (String)rolesIterator.next();
+ result.add(new SimplePrincipal(roleName));
+ }
+ }
+ }
+ }
+
+ if (this.isExcludeMissingMethods() == false)
+ {
+ // If no permissions were assigned to the method, anybody can access it
+ if (result.isEmpty())
+ {
+ result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ }
+ }
+
+ return result;
+ }
+
+ /** Check to see if there was a method-permission or exclude-list statement
+ * for the given method.
+ *
+ * @param methodName - the method name
+ * @param params - the method parameter signature
+ * @param iface - the method interface type
+ * @return true if a matching method permission exists, false if no match
+ */
+ public boolean hasMethodPermission(String methodName, Class[] params,
+ InvocationType iface)
+ {
+ // First check the excluded method list as this takes priority
+ Iterator iterator = getExcludedMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ return true;
+ }
+ }
+
+ // Check the permissioned methods list
+ iterator = getPermissionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // Cluster configuration methods
+ public boolean isClustered()
+ {
+ return this.clustered;
+ }
+
+ public boolean isCallByValue()
+ {
+ return callByValue;
+ }
+
+ public boolean isExcludeMissingMethods()
+ {
+ return application.isExcludeMissingMethods();
+ }
+
+ public ClusterConfigMetaData getClusterConfigMetaData()
+ {
+ if (clusterConfig == null)
+ {
+ clusterConfig = getContainerConfiguration().getClusterConfigMetaData();
+ if (clusterConfig == null)
+ {
+ clusterConfig = new ClusterConfigMetaData();
+ }
+ /* All beans associated with a container are the same type
+ so this can be done more than once without harm */
+ clusterConfig.init(this);
+ }
+ return this.clusterConfig;
+ }
+
+ public IorSecurityConfigMetaData getIorSecurityConfigMetaData()
+ {
+ return iorSecurityConfig;
+ }
+
+ public boolean getExceptionRollback()
+ {
+ return exceptionRollback;
+ }
+
+ public boolean getTimerPersistence()
+ {
+ return timerPersistence;
+ }
+
+ /** Called to parse the ejb-jar.xml enterprise-beans child ejb elements
+ * @param element one of session/entity/message-driven
+ * @throws DeploymentException
+ */
+ public void importEjbJarXml(Element element)
+ throws DeploymentException
+ {
+ // set the ejb-name
+ ejbName = getElementContent(getUniqueChild(element, "ejb-name"));
+
+ // Set the interfaces classes for all types but MessageDriven
+ if (isMessageDriven() == false)
+ {
+ homeClass = getElementContent(getOptionalChild(element, "home"));
+ remoteClass = getElementContent(getOptionalChild(element, "remote"));
+ localHomeClass = getElementContent(getOptionalChild(element,
+ "local-home"));
+ localClass = getElementContent(getOptionalChild(element, "local"));
+ }
+ ejbClass = getElementContent(getUniqueChild(element, "ejb-class"));
+
+ // set the environment entries
+ Iterator iterator = getChildrenByTagName(element, "env-entry");
+
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element)iterator.next();
+
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // set the ejb references
+ iterator = getChildrenByTagName(element, "ejb-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element)iterator.next();
+
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // set the ejb local references
+ iterator = getChildrenByTagName(element, "ejb-local-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element)iterator.next();
+
+ EjbLocalRefMetaData ejbLocalRefMetaData = new EjbLocalRefMetaData();
+ ejbLocalRefMetaData.importEjbJarXml(ejbLocalRef);
+
+ ejbLocalReferences.put(ejbLocalRefMetaData.getName(),
+ ejbLocalRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element)iterator.next();
+ new ServiceRefDelegate().newServiceRefMetaData();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // set the security roles references
+ iterator = getChildrenByTagName(element, "security-role-ref");
+
+ while (iterator.hasNext())
+ {
+ Element secRoleRef = (Element)iterator.next();
+ SecurityRoleRefMetaData securityRoleRefMetaData = new SecurityRoleRefMetaData();
+ securityRoleRefMetaData.importEjbJarXml(secRoleRef);
+ securityRoleReferences.add(securityRoleRefMetaData);
+ }
+
+ // The security-identity element
+ Element securityIdentityElement = getOptionalChild(element,
+ "security-identity");
+ if (securityIdentityElement != null)
+ {
+ securityIdentity = new SecurityIdentityMetaData();
+ securityIdentity.importEjbJarXml(securityIdentityElement);
+ }
+
+ // set the resource references
+ iterator = getChildrenByTagName(element, "resource-ref");
+
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+
+ resourceReferences.put(resourceRefMetaData.getRefName(),
+ resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // set the message destination references
+ iterator = getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element)iterator.next();
+
+ MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
+ messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
+
+ messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
+ }
+ }
+
+ /** Called to parse the jboss.xml enterprise-beans child ejb elements
+ * @param element one of session/entity/message-driven
+ * @throws DeploymentException
+ */
+ public void importJbossXml(Element element) throws DeploymentException
+ {
+ // we must not set defaults here, this might never be called
+
+ // set the jndi name, (optional)
+ jndiName = getElementContent(getOptionalChild(element, "jndi-name"));
+
+ // set the JNDI name under with the local home interface should be
+ // bound (optional)
+ localJndiName = getElementContent(getOptionalChild(element, "local-jndi-name"));
+
+ // Determine if the bean should use by value call semantics
+ String callByValueElt = getElementContent(getOptionalChild(element, "call-by-value"), (callByValue ? "True" : "False"));
+ callByValue = callByValueElt.equalsIgnoreCase("True");
+
+ // set the configuration (optional)
+ configurationName = getElementContent(getOptionalChild(element, "configuration-name"));
+ if (configurationName != null && getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null)
+ {
+ throw new DeploymentException("configuration '" + configurationName + "' not found in standardjboss.xml or jboss.xml");
+ }
+
+ // Get the security proxy
+ securityProxy = getElementContent(getOptionalChild(element, "security-proxy"), securityProxy);
+
+ // Throw an exception when marked rollback with no exception thrown
+ exceptionRollback = MetaData.getOptionalChildBooleanContent(element, "exception-on-rollback", false);
+
+ // Whether to persist ejb timers across redeployments
+ timerPersistence = MetaData.getOptionalChildBooleanContent(element, "timer-persistence", true);
+
+ // update the resource references (optional)
+ Iterator iterator = getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)resourceReferences.get(resRefName);
+
+ if (resourceRefMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ resourceRefMetaData.importJbossXml(resourceRef);
+ }
+
+ // Set the resource-env-ref deployed jndi names
+ iterator = getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // update the message destination references (optional)
+ iterator = getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element)iterator.next();
+ String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name"));
+ MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData)messageDestinationReferences.get(messageDestinationRefName);
+ if (messageDestinationRefMetaData == null)
+ throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss.xml but not in ejb-jar.xml");
+ messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
+ }
+
+ // set the external ejb-references (optional)
+ iterator = getChildrenByTagName(element, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element)iterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+
+ //handle the ejb-local-ref elements
+ iterator = getChildrenByTagName(element, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element)iterator.next();
+ String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
+
+ EjbLocalRefMetaData ejbLocalRefMetaData = getEjbLocalRefByName(ejbLocalRefName);
+ if (ejbLocalRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ejbLocalRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element)iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // Get the security identity
+ Element securityIdentityElement = getOptionalChild(element, "security-identity");
+ if (securityIdentityElement != null)
+ {
+ if (securityIdentity == null)
+ throw new DeploymentException(ejbName + ", security-identity in jboss.xml has no match in ejb-jar.xml");
+ String runAsPrincipal = getElementContent(getUniqueChild(securityIdentityElement,
+ "run-as-principal"), securityIdentity.getRunAsPrincipalName());
+ securityIdentity.setRunAsPrincipalName(runAsPrincipal);
+ }
+
+ // Get the ejbTimeout caller identity
+ Element ejbTimeoutIdentityElement = getOptionalChild(element, "ejb-timeout-identity");
+ if (ejbTimeoutIdentityElement != null)
+ {
+ ejbTimeoutIdentity = new SecurityIdentityMetaData();
+ String runAsPrincipal = getElementContent(getUniqueChild(ejbTimeoutIdentityElement,
+ "run-as-principal"), null);
+ ejbTimeoutIdentity.setRunAsRoleName("ejbTimeout");
+ if( runAsPrincipal != null && runAsPrincipal.length() > 0 )
+ ejbTimeoutIdentity.setRunAsPrincipalName(runAsPrincipal);
+ else
+ ejbTimeoutIdentity.setUseCallerIdentity(true);
+ }
+
+ // Method attributes of the bean
+ Element mas = getOptionalChild(element, "method-attributes");
+ if (mas != null)
+ {
+ // read in the read-only methods
+ iterator = getChildrenByTagName(mas, "method");
+ while (iterator.hasNext())
+ {
+ MethodAttributes ma = new MethodAttributes();
+ Element maNode = (Element)iterator.next();
+ ma.pattern = getElementContent(getUniqueChild(maNode, "method-name"));
+ ma.readOnly = getOptionalChildBooleanContent(maNode, "read-only");
+ ma.idempotent = getOptionalChildBooleanContent(maNode, "idempotent");
+ String txTimeout = getOptionalChildContent(maNode, "transaction-timeout");
+ try
+ {
+ if (txTimeout != null && txTimeout.length() > 0)
+ ma.txTimeout = Integer.parseInt(txTimeout);
+ }
+ catch (Exception ignore)
+ {
+ log.debug("Ignoring transaction-timeout '" + txTimeout + "'", ignore);
+ }
+ methodAttributes.add(ma);
+ }
+ }
+
+ // Invokers
+ // If no invoker bindings have been defined they will be defined
+ // in EntityMetaData, or SessionMetaData
+ Element inv = getOptionalChild(element, "invoker-bindings");
+ if (inv != null)
+ {
+ // read in the read-only methods
+ iterator = getChildrenByTagName(inv, "invoker");
+ invokerBindings = new HashMap();
+ while (iterator.hasNext())
+ {
+ Element node = (Element)iterator.next();
+ String invokerBindingName = getUniqueChildContent(node, "invoker-proxy-binding-name");
+ String jndiBinding = getOptionalChildContent(node, "jndi-name");
+
+ if (jndiBinding == null)
+ {
+ jndiBinding = getJndiName(); // default to jndiName
+ }
+ invokerBindings.put(invokerBindingName, jndiBinding);
+
+ // set the external ejb-references (optional)
+ Iterator ejbrefiterator = getChildrenByTagName(node, "ejb-ref");
+ while (ejbrefiterator.hasNext())
+ {
+ Element ejbRef = (Element)ejbrefiterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbRefMetaData.importJbossXml(invokerBindingName, ejbRef);
+ }
+ }
+ }
+
+ // Determine if the bean is to be deployed in the cluster (more
+ // advanced config will be added in the future)
+ String clusteredElt = getElementContent(getOptionalChild(element, "clustered"), (clustered ? "True" : "False"));
+ clustered = clusteredElt.equalsIgnoreCase("True");
+
+ Element clusterConfigElement = getOptionalChild(element, "cluster-config");
+ if (clusterConfigElement != null)
+ {
+ this.clusterConfig = new ClusterConfigMetaData();
+ clusterConfig.init(this);
+ clusterConfig.importJbossXml(clusterConfigElement);
+ }
+
+ //Get depends object names
+ for (Iterator dependsElements = getChildrenByTagName(element, "depends"); dependsElements.hasNext();)
+ {
+ Element dependsElement = (Element)dependsElements.next();
+ String dependsName = getElementContent(dependsElement);
+ depends.add(ObjectNameFactory.create(dependsName));
+ } // end of for ()
+
+ // ior-security-config optional element
+ Element iorSecurityConfigEl = getOptionalChild(element, "ior-security-config");
+ if (iorSecurityConfigEl != null)
+ {
+ iorSecurityConfig = new IorSecurityConfigMetaData(iorSecurityConfigEl);
+ }
+
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/ClientMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/ClientMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/ClientMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,326 @@
+/*
+ * 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.metadata;
+
+// $Id: ClientMetaData.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.net.URLClassLoader;
+
+/** The metdata data from a j2ee application-client.xml descriptor
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ * @version $Revision: 69712 $
+ */
+public class ClientMetaData
+{
+ /** The application-client/display-name */
+ private String displayName;
+ /** The location for the server side client context ENC bindings */
+ private String jndiName;
+ /** An ArrayList<EnvEntryMetaData> for the env-entry element(s) */
+ private ArrayList environmentEntries = new ArrayList();
+ /** A HashMap<String, EjbRefMetaData> for the ejb-ref element(s) */
+ private HashMap ejbReferences = new HashMap();
+ /** The HashMap<String, ServiceRefMetaData> service-ref element(s) info */
+ private HashMap<String,ServiceRefMetaData> serviceReferences = new HashMap<String,ServiceRefMetaData>();
+ /** A HashMap<String, ResourceRefMetaData> resource-ref element(s) info */
+ private HashMap resourceReferences = new HashMap();
+ /** A HashMap<String, ResourceEnvRefMetaData> resource-env-ref element(s) info */
+ private HashMap resourceEnvReferences = new HashMap();
+ /** A HashMap<String, ArrayList<ResourceEnvRefMetaData>> of
+ * message-destination-ref that resolve to a jndi-name via a message-destination
+ * via a message-destination-link
+ */
+ private HashMap resourceEnvReferenceLinks = new HashMap();
+ /** The JAAS callback handler */
+ private String callbackHandler;
+
+ /** The ClassLoader to load additional resources */
+ private URLClassLoader resourceCl;
+
+ /** Set the ClassLoader to load additional resources */
+ public void setResourceClassLoader(URLClassLoader resourceCl)
+ {
+ this.resourceCl = resourceCl;
+ }
+
+ /** The application-client/display-name
+ * @return application-client/display-name value
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ /** The location for the server side client context ENC bindings
+ * @return the JNDI name for the server side client context ENC bindings. This
+ * is either the jboss-client/jndi-name or the application-client/display-name
+ * value.
+ */
+ public String getJndiName()
+ {
+ String name = jndiName;
+ if( name == null )
+ name = displayName;
+ return name;
+ }
+
+ /**
+ * @return ArrayList<EnvEntryMetaData>
+ */
+ public ArrayList getEnvironmentEntries()
+ {
+ return environmentEntries;
+ }
+ /**
+ * @return HashMap<EjbRefMetaData>
+ */
+ public HashMap getEjbReferences()
+ {
+ return ejbReferences;
+ }
+ /**
+ * @return HashMap<ResourceRefMetaData>
+ */
+ public HashMap getResourceReferences()
+ {
+ return resourceReferences;
+ }
+ /**
+ * @return HashMap<ResourceEnvRefMetaData>
+ */
+ public HashMap getResourceEnvReferences()
+ {
+ return resourceEnvReferences;
+ }
+ /**
+ * @return The CallbackHandler if defined, null otherwise
+ */
+ public String getCallbackHandler()
+ {
+ return callbackHandler;
+ }
+ /**
+ * @return HashMap<ServiceRefMetaData>
+ */
+ public HashMap<String,ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public void importClientXml(Element element)
+ throws DeploymentException
+ {
+ displayName = MetaData.getOptionalChildContent(element, "display-name");
+
+ // set the environment entries
+ Iterator iterator = MetaData.getChildrenByTagName(element, "env-entry");
+
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element) iterator.next();
+
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // set the ejb references
+ iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // The callback-handler element
+ Element callbackElement = MetaData.getOptionalChild(element,
+ "callback-handler");
+ if (callbackElement != null)
+ {
+ callbackHandler = MetaData.getElementContent(callbackElement);
+ }
+
+ // set the resource references
+ iterator = MetaData.getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+
+ resourceReferences.put(resourceRefMetaData.getRefName(),
+ resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // Parse the message-destination-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ /* A message-destination-ref is linked to a jndi-name either via
+ the message-destination-ref/message-destination-ref-name mapping to
+ a jboss resource-env-ref/resource-env-ref-name if there is no
+ message-destination-link, or by the message-destination-link ->
+ message-destination/message-destination-name mapping to a jboss
+ resource-env-ref/resource-env-ref-name.
+ */
+ String refName = refMetaData.getRefName();
+ String link = refMetaData.getLink();
+ if( link != null )
+ {
+ ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(link);
+ if( linkedRefs == null )
+ {
+ linkedRefs = new ArrayList();
+ resourceEnvReferenceLinks.put(link, linkedRefs);
+ }
+ linkedRefs.add(refMetaData);
+ }
+ resourceEnvReferences.put(refName, refMetaData);
+ }
+ }
+
+ public void importJbossClientXml(Element element) throws DeploymentException
+ {
+ jndiName = MetaData.getOptionalChildContent(element, "jndi-name");
+
+ // Get the JNDI names of ejb-refs
+ Iterator iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ String ejbRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // Get the JNDI name binding for resource-refs
+ iterator = MetaData.getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData resourceRefMetaData =
+ (ResourceRefMetaData) resourceReferences.get(resRefName);
+ if (resourceRefMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ resourceRefMetaData.importJbossXml(resourceRef);
+ }
+
+ // Get the JNDI name binding resource-env-refs
+ iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData =
+ (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ // Try the resourceEnvReferenceLinks
+ ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(resRefName);
+ if( linkedRefs != null )
+ {
+ for(int n = 0; n < linkedRefs.size(); n ++)
+ {
+ refMetaData = (ResourceEnvRefMetaData) linkedRefs.get(n);
+ refMetaData.importJbossXml(resourceRef);
+ }
+ }
+ else
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ }
+ else
+ {
+ refMetaData.importJbossXml(resourceRef);
+ }
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/WebMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/WebMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/WebMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1414 @@
+/*
+ * 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.metadata;
+
+// $Id: WebMetaData.java 74786 2008-06-18 10:21:59Z darran.lofthouse at jboss.com $
+
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+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 org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.RunAsIdentity;
+import org.jboss.security.SecurityRoleMetaData;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+/** A representation of the web.xml and jboss-web.xml deployment
+ * descriptors as used by the AbstractWebContainer web container integration
+ * support class.
+ *
+ * @see XmlLoadable
+ * @see org.jboss.web.AbstractWebContainer
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 74786 $
+ */
+public class WebMetaData extends MetaData
+{
+ private static Logger log = Logger.getLogger(WebMetaData.class);
+
+ /** The web.xml servlet <String, String> */
+ private HashMap servletClassNames = new HashMap();
+
+ /** The web.xml servlet-param <String,String> */
+ private HashMap servletParams = new HashMap();
+
+ /** The web.xml context-param <String,String> */
+ private HashMap contextParams = new HashMap();
+
+ /** The web.xml servlet-mapping <String, String> */
+ private HashMap servletMappings = new HashMap();
+
+ /** The web.xml resource-refs <String, String> */
+ private HashMap resourceReferences = new HashMap();
+
+ /** The web.xml resource-env-refs <String, String> */
+ private HashMap resourceEnvReferences = new HashMap();
+
+ /** The web.xml message-destination-refs <String, MessageDestinationRefMetaData> */
+ private HashMap messageDestinationReferences = new HashMap();
+
+ /** The web.xml message-destination <String, MessageDestinationMetaData> */
+ private HashMap messageDestinations = new HashMap();
+
+ /** web.xml env-entrys */
+ private ArrayList environmentEntries = new ArrayList();
+
+ /** web.xml security-constraint <WebSecurityMetaData> */
+ private ArrayList securityContraints = new ArrayList();
+
+ /** The HashMap<String, SecurityRoleMetaData> for the security-roles */
+ private HashMap securityRoles = new HashMap();
+
+ /** web.xml ejb-refs */
+ private HashMap ejbReferences = new HashMap();
+
+ /** web.xml ejb-local-refs */
+ private HashMap ejbLocalReferences = new HashMap();
+
+ /** The web.xml service-refs */
+ private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
+
+ /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
+ private HashMap securityRoleReferences = new HashMap();
+
+ /** The web.xml servlet/run-as <String servlet-name, String role> */
+ private HashMap runAsNames = new HashMap();
+
+ /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity> */
+ private HashMap runAsIdentity = new HashMap();
+
+ /** The web.xml distributable flag */
+ private boolean distributable = false;
+
+ /** The jboss-web.xml class-loading.java2ClassLoadingCompliance flag */
+ private boolean java2ClassLoadingCompliance = false;
+
+ /** The jboss-web.xml class-loading jboss class loader flag */
+ private boolean useJBossWebLoader = false;
+
+ /** The jboss-web.xml class-loading/loader-repository */
+ private LoaderRepositoryConfig loaderConfig;
+
+ /** The war context root as specified at the jboss-web.xml descriptor level. */
+ private String contextRoot;
+
+ /** The JACC context id for the container */
+ private String jaccContextID;
+
+ /** The jboss-web.xml server container virtual hosts the war should be deployed into */
+ private ArrayList virtualHosts = new ArrayList();
+
+ /** The jboss-web.xml JNDI name of the security domain implementation */
+ private String securityDomain;
+
+ /** JBAS-1824: Flag whether WebResourcePermission(url,null) needed for rolename '*' */
+ private boolean jaccRoleNameStar = false;
+
+ /** The jboss-web.xml securityDomain flushOnSessionInvalidation attribute */
+ private boolean flushOnSessionInvalidation;
+
+ /** A HashMap<String, String> for webservice description publish locations */
+ private HashMap wsdlPublishLocationMap = new HashMap();
+
+ /** True if this is a web service deployment */
+ private boolean webServiceDeployment;
+
+ /** The optional JBossWS config-name */
+ private String configName;
+
+ /** The optional JBossWS config-file */
+ private String configFile;
+
+ /** The web context class loader used to create the java:comp context */
+ private ClassLoader encLoader;
+
+ /** The web context class loader, used to create the ws4ee service endpoint */
+ private ClassLoader cxtLoader;
+
+ /** ArrayList<ObjectName> of the web app dependencies */
+ private ArrayList depends = new ArrayList();
+
+ public static final int SESSION_INVALIDATE_ACCESS = 0;
+
+ public static final int SESSION_INVALIDATE_SET_AND_GET = 1;
+
+ public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET = 2;
+
+ public static final int SESSION_INVALIDATE_SET = 3;
+
+ private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
+
+ public static final int REPLICATION_TYPE_SYNC = 0;
+
+ public static final int REPLICATION_TYPE_ASYNC = 1;
+
+ /**
+ * @deprecated Since JBoss3.2.6.
+ */
+ private int replicationType = REPLICATION_TYPE_SYNC;
+
+ /** Specify the session replication granularity level: session --- whole session level,
+ * attribute --- per attribute change, field --- fine grained user object level.
+ *
+ */
+ public static final int REPLICATION_GRANULARITY_SESSION = 0;
+
+ public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1;
+
+ public static final int REPLICATION_GRANULARITY_FIELD = 2;
+
+ private int replicationGranularity = REPLICATION_GRANULARITY_SESSION;
+
+ /**
+ * If the replication granularity is FIELD, specify whether to use batch mode
+ * for pojo replication or not.
+ */
+ private boolean replicationFieldBatchMode = true;
+
+ /** Should the context use session cookies or use default */
+ private int sessionCookies = SESSION_COOKIES_DEFAULT;
+
+ public static final int SESSION_COOKIES_DEFAULT = 0;
+
+ public static final int SESSION_COOKIES_ENABLED = 1;
+
+ public static final int SESSION_COOKIES_DISABLED = 2;
+
+ /** The ClassLoader to load additional resources */
+ private URLClassLoader resourceCl;
+
+ /** Set the ClassLoader to load additional resources */
+ public void setResourceClassLoader(URLClassLoader resourceCl)
+ {
+ this.resourceCl = resourceCl;
+ }
+
+ /** Return an iterator of the env-entry mappings.
+ @return Iterator of EnvEntryMetaData objects.
+ */
+ public Iterator getEnvironmentEntries()
+ {
+ return environmentEntries.iterator();
+ }
+
+ /**
+ *
+ * @param environmentEntries - Collection<EnvEntryMetaData>
+ */
+ public void setEnvironmentEntries(Collection environmentEntries)
+ {
+ this.environmentEntries.clear();
+ this.environmentEntries.addAll(environmentEntries);
+ }
+
+ /** Return an iterator of the ejb-ref mappings.
+ @return Iterator of EjbRefMetaData objects.
+ */
+ public Iterator getEjbReferences()
+ {
+ return ejbReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param ejbReferences - Map<String, EjbRefMetaData>
+ */
+ public void setEjbReferences(Map ejbReferences)
+ {
+ this.ejbReferences.clear();
+ this.ejbReferences.putAll(ejbReferences);
+ }
+
+ /** Return an iterator of the ejb-local-ref mappings.
+ @return Iterator of EjbLocalRefMetaData objects.
+ */
+ public Iterator getEjbLocalReferences()
+ {
+ return ejbLocalReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param ejbReferences - Map<String, EjbRefMetaData>
+ */
+ public void setEjbLocalReferences(Map ejbReferences)
+ {
+ this.ejbLocalReferences.clear();
+ this.ejbLocalReferences.putAll(ejbReferences);
+ }
+
+ /** Return an iterator of the resource-ref mappings.
+ @return Iterator of ResourceRefMetaData objects.
+ */
+ public Iterator getResourceReferences()
+ {
+ return resourceReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param resourceReferences - Map<String, ResourceRefMetaData>
+ */
+ public void setResourceReferences(Map resourceReferences)
+ {
+ this.resourceReferences.clear();
+ this.resourceReferences.putAll(resourceReferences);
+ }
+
+ /** Return an iterator of the resource-ref mappings.
+ @return Iterator of ResourceEnvRefMetaData objects.
+ */
+ public Iterator getResourceEnvReferences()
+ {
+ return resourceEnvReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param resourceReferences - Map<String, ResourceEnvRefMetaData>
+ */
+ public void setResourceEnvReferences(Map resourceReferences)
+ {
+ this.resourceEnvReferences.clear();
+ this.resourceEnvReferences.putAll(resourceReferences);
+ }
+
+ /**
+ * Return an iterator of message-destination-refs.
+ *
+ * @return Iterator of MessageDestinationRefMetaData objects.
+ */
+ public Iterator getMessageDestinationReferences()
+ {
+ return messageDestinationReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param messageDestinationReferences - Map<String, MessageDestinationRefMetaData>
+ */
+ public void setMessageDestinationReferences(Map messageDestinationReferences)
+ {
+ this.messageDestinationReferences.clear();
+ this.messageDestinationReferences.putAll(messageDestinationReferences);
+ }
+
+ /**
+ * Get a message destination metadata
+ *
+ * @param name the name of the message destination
+ * @return the message destination metadata
+ */
+ public MessageDestinationMetaData getMessageDestination(String name)
+ {
+ return (MessageDestinationMetaData) messageDestinations.get(name);
+ }
+
+ /**
+ *
+ * @param messageDestinations - Map<String, MessageDestinationMetaData>
+ */
+ public void setMessageDestination(Map messageDestinations)
+ {
+ this.messageDestinations.clear();
+ this.messageDestinations.putAll(messageDestinations);
+ }
+
+ public Map<String, ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public void setServiceReferences(Map<String, ServiceRefMetaData> serviceReferences)
+ {
+ this.serviceReferences.clear();
+ this.serviceReferences.putAll(serviceReferences);
+ }
+
+ /** This the the jboss-web.xml descriptor context-root and it
+ *is only meaningful if a war is deployed outside of an ear.
+ */
+ public String getContextRoot()
+ {
+ return contextRoot;
+ }
+
+ public void setContextRoot(String contextRoot)
+ {
+ this.contextRoot = contextRoot;
+ }
+
+ public String getConfigFile()
+ {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile)
+ {
+ this.configFile = configFile;
+ }
+
+ public String getConfigName()
+ {
+ return configName;
+ }
+
+ public void setConfigName(String configName)
+ {
+ this.configName = configName;
+ }
+
+ /** Get the optional wsdl publish location from jboss-web.xml. */
+ public String getWsdlPublishLocationByName(String name)
+ {
+ return (String) wsdlPublishLocationMap.get(name);
+ }
+
+ /**
+ *
+ * @param wsdlPublishLocationMap - Map<String, String>
+ */
+ public void setWsdlPublishLocationMap(Map wsdlPublishLocationMap)
+ {
+ this.wsdlPublishLocationMap.clear();
+ this.wsdlPublishLocationMap.putAll(wsdlPublishLocationMap);
+ }
+
+ public boolean isWebServiceDeployment()
+ {
+ return webServiceDeployment;
+ }
+
+ public void setWebServiceDeployment(boolean webServiceDeployment)
+ {
+ this.webServiceDeployment = webServiceDeployment;
+ }
+
+ public String getJaccContextID()
+ {
+ return jaccContextID;
+ }
+
+ public void setJaccContextID(String jaccContextID)
+ {
+ this.jaccContextID = jaccContextID;
+ }
+
+ /** Return the optional security-domain jboss-web.xml element.
+ @return The jndiName of the security manager implementation that is
+ responsible for security of the web application. May be null if
+ there was no security-domain specified in the jboss-web.xml
+ descriptor.
+ */
+ public String getSecurityDomain()
+ {
+ return securityDomain;
+ }
+
+ /** Set the security domain for this web application
+ */
+ public void setSecurityDomain(String securityDomain)
+ {
+ this.securityDomain = securityDomain;
+ }
+
+ /**
+ * JBAS-1824: Specify whether a WebResourcePermission(url,null)
+ * needs to be generated by the container
+ * @return
+ */
+ public boolean isJaccRoleNameStar()
+ {
+ return jaccRoleNameStar;
+ }
+
+ /**
+ * JBAS-1824: Specify whether a WebResourcePermission(url,null)
+ * needs to be generated by the container
+ * @return
+ */
+ public void setJaccRoleNameStar(boolean jaccRoleNameStar)
+ {
+ this.jaccRoleNameStar = jaccRoleNameStar;
+ }
+
+ /** The flag indicating whether the associated security domain cache
+ * should be flushed when the session is invalidated.
+ * @return true if the flush should occur, false otherwise.
+ */
+ public boolean isFlushOnSessionInvalidation()
+ {
+ return flushOnSessionInvalidation;
+ }
+
+ /** The flag indicating whether the associated security domain cache
+ * should be flushed when the session is invalidated.
+ * @param flag - true if the flush should occur, false otherwise.
+ */
+ public void setFlushOnSessionInvalidation(boolean flag)
+ {
+ this.flushOnSessionInvalidation = flag;
+ }
+
+ /** Get the security-constraint settings
+ */
+ public Iterator getSecurityContraints()
+ {
+ return securityContraints.iterator();
+ }
+
+ /**
+ *
+ * @param securityContraints - Collection<WebSecurityMetaData>
+ */
+ public void setSecurityConstraints(Collection securityContraints)
+ {
+ this.securityContraints.clear();
+ this.securityContraints.addAll(securityContraints);
+ }
+
+ /**
+ * @return <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
+ */
+ public Map getSecurityRoleRefs()
+ {
+ return this.securityRoleReferences;
+ }
+
+ /**
+ *
+ * @param servletName
+ * @return List<SecurityRoleRefMetaData> for the given servlet name
+ */
+ public List getSecurityRoleRefs(String servletName)
+ {
+ List roles = (List) this.securityRoleReferences.get(servletName);
+ return roles;
+ }
+
+ /**
+ *
+ * @param securityRoleReferences - <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
+ */
+ public void setSecurityRoleReferences(Map securityRoleReferences)
+ {
+ this.securityRoleReferences.clear();
+ this.securityRoleReferences.putAll(securityRoleReferences);
+ }
+
+ /**
+ * Get the security-role names from the web.xml descriptor
+ * @return Set<String> of the security-role names from the web.xml
+ */
+ public Set getSecurityRoleNames()
+ {
+ return new HashSet(securityRoles.keySet());
+ }
+
+ /** Get the optional map of security role/user mapping.
+ * @return Map<String, SecurityRoleMetaData>
+ */
+ public Map getSecurityRoles()
+ {
+ return new HashMap(securityRoles);
+ }
+
+ /**
+ *
+ * @param securityRoles - Map<String, SecurityRoleMetaData>
+ */
+ public void setSecurityRoles(Map securityRoles)
+ {
+ this.securityRoles.clear();
+ this.securityRoles.putAll(securityRoles);
+ }
+
+ /**
+ *
+ * @param userName
+ * @return Set<String>
+ */
+ public Set getSecurityRoleNamesByPrincipal(String userName)
+ {
+ HashSet roleNames = new HashSet();
+ Iterator it = securityRoles.values().iterator();
+ while (it.hasNext())
+ {
+ SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it.next();
+ if (srMetaData.getPrincipals().contains(userName))
+ roleNames.add(srMetaData.getRoleName());
+ }
+ return roleNames;
+ }
+
+ /**
+ * Access the RunAsIdentity associated with the given servlet
+ * @param servletName - the servlet-name from the web.xml
+ * @return RunAsIdentity for the servet if one exists, null otherwise
+ */
+ public RunAsIdentity getRunAsIdentity(String servletName)
+ {
+ RunAsIdentity runAs = (RunAsIdentity) runAsIdentity.get(servletName);
+ if (runAs == null)
+ {
+ // Check for a web.xml run-as only specification
+ synchronized (runAsIdentity)
+ {
+ String roleName = (String) runAsNames.get(servletName);
+ if (roleName != null)
+ {
+ runAs = new RunAsIdentity(roleName, null);
+ runAsIdentity.put(servletName, runAs);
+ }
+ }
+ }
+ return runAs;
+ }
+
+ /**
+ *
+ * @return servlet/run-as <String servlet-name, RunAsIdentity>
+ */
+ public Map getRunAsIdentity()
+ {
+ return runAsIdentity;
+ }
+
+ /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity>
+ */
+ public void setRunAsIdentity(Map runAsIdentity)
+ {
+ this.runAsIdentity.clear();
+ this.runAsIdentity.putAll(runAsIdentity);
+ }
+
+ /**
+ * Get the servlet-name values from the web.xml descriptor
+ * @return Set<String> of the servlet-names from the servlet-mappings
+ */
+ public HashMap getServletMappings()
+ {
+ return servletMappings;
+ }
+
+ /** The web.xml servlet-mapping */
+ /**
+ * servlet-mapping/serlvet-name to url-pattern mapping
+ * @param servletMappings - Map<String, String>
+ */
+ public void setServletMappings(Map servletMappings)
+ {
+ this.servletMappings.clear();
+ this.servletMappings.putAll(servletMappings);
+ }
+
+ /**
+ * Get the servlet-name values from the web.xml descriptor
+ * @return Set<String> of the servlet-names from the servlet-mappings
+ */
+ public Set getServletNames()
+ {
+ return new HashSet(servletMappings.keySet());
+ }
+
+ /**
+ <<<<<<< .working
+ =======
+ * Get the init parameter map for a servlet or an empty map if there are none.
+ */
+ public Map getServletParams(String servletName)
+ {
+ Map params = (Map) servletParams.get(servletName);
+ if (params == null)
+ {
+ params = new HashMap();
+ servletParams.put(servletName, params);
+ }
+ return params;
+ }
+
+ /**
+ >>>>>>> .merge-right.r68814
+ * Get the servlet-name/servlet-class mapping from the web.xml descriptor
+ * @return Map<String, String> of the servlet-name/servlet-class mapping from web.xml
+ */
+ public Map getServletClassMap()
+ {
+ return new HashMap(servletClassNames);
+ }
+
+ /**
+ * Merge the security role/principal mapping defined in jboss-web.xml
+ * with the one defined at jboss-app.xml.
+ */
+ public void mergeSecurityRoles(Map applRoles)
+ {
+ Iterator it = applRoles.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ String roleName = (String) entry.getKey();
+ SecurityRoleMetaData appRole = (SecurityRoleMetaData) entry.getValue();
+ SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
+ if (srMetaData != null)
+ {
+ Set principalNames = appRole.getPrincipals();
+ srMetaData.addPrincipalNames(principalNames);
+ }
+ else
+ {
+ securityRoles.put(roleName, entry.getValue());
+ }
+ }
+ }
+
+ /** The servlet container virtual host the war should be deployed into. If
+ null then the servlet container default host should be used.
+ */
+ public Iterator getVirtualHosts()
+ {
+ return virtualHosts.iterator();
+ }
+
+ /**
+ *
+ * @param virtualHosts - Collection<String>
+ */
+ public void setVirtualHosts(Collection virtualHosts)
+ {
+ this.virtualHosts.clear();
+ this.virtualHosts.addAll(virtualHosts);
+ }
+
+ /**
+ The distributable flag.
+ @return true if the web-app is marked distributable
+ */
+ public boolean getDistributable()
+ {
+ return distributable;
+ }
+
+ /**
+ * Mark the web-app as distributable
+ * @param distributable - true for distributable
+ */
+ public void setDistributable(boolean distributable)
+ {
+ this.distributable = distributable;
+ }
+
+ /** Access the web application depends
+ * @return Iterator of JMX ObjectNames the web app depends on.
+ */
+ public Collection getDepends()
+ {
+ return depends;
+ }
+
+ /**
+ @param depends - Collection<ObjectName> of the web app dependencies
+ */
+ public void setDepends(Collection depends)
+ {
+ this.depends.clear();
+ this.depends.addAll(depends);
+ }
+
+ /** A 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
+ */
+ public boolean getJava2ClassLoadingCompliance()
+ {
+ return java2ClassLoadingCompliance;
+ }
+
+ public void setJava2ClassLoadingCompliance(boolean flag)
+ {
+ java2ClassLoadingCompliance = flag;
+ }
+
+ public boolean isUseJBossWebLoader()
+ {
+ return useJBossWebLoader;
+ }
+
+ public void setUseJBossWebLoader(boolean flag)
+ {
+ useJBossWebLoader = flag;
+ }
+
+ public LoaderRepositoryConfig getLoaderConfig()
+ {
+ return loaderConfig;
+ }
+
+ public void setLoaderConfig(LoaderRepositoryConfig loaderConfig)
+ {
+ this.loaderConfig = loaderConfig;
+ }
+
+ public ClassLoader getENCLoader()
+ {
+ return encLoader;
+ }
+
+ public void setENCLoader(ClassLoader encLoader)
+ {
+ this.encLoader = encLoader;
+ }
+
+ public ClassLoader getContextLoader()
+ {
+ return cxtLoader;
+ }
+
+ /** Make sure this is called during performDeploy */
+ public void setContextLoader(ClassLoader cxtLoader)
+ {
+ this.cxtLoader = cxtLoader;
+ }
+
+ public int getSessionCookies()
+ {
+ return this.sessionCookies;
+ }
+
+ public void setSessionCookies(int sessionCookies)
+ {
+ this.sessionCookies = sessionCookies;
+ }
+
+ public int getInvalidateSessionPolicy()
+ {
+ return this.invalidateSessionPolicy;
+ }
+
+ public void setInvalidateSessionPolicy(int invalidateSessionPolicy)
+ {
+ this.invalidateSessionPolicy = invalidateSessionPolicy;
+ }
+
+ public int getReplicationType()
+ {
+ return replicationType;
+ }
+
+ public int getReplicationGranularity()
+ {
+ return replicationGranularity;
+ }
+
+ public void setReplicationGranularity(int replicationGranularity)
+ {
+ this.replicationGranularity = replicationGranularity;
+ }
+
+ public boolean getReplicationFieldBatchMode()
+ {
+ return replicationFieldBatchMode;
+ }
+
+ public void importXml(Element element) throws DeploymentException
+ {
+ String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
+ if (rootTag.equals("web-app"))
+ {
+ importWebXml(element);
+ }
+ else if (rootTag.equals("jboss-web"))
+ {
+ importJBossWebXml(element);
+ }
+ }
+
+ /** Parse the elements of the web-app element used by the integration layer.
+ */
+ protected void importWebXml(Element webApp) throws DeploymentException
+ {
+ // Parse the web-app/servlet/security-role-ref + run-as elements
+ Iterator iterator = getChildrenByTagName(webApp, "servlet");
+ while (iterator.hasNext())
+ {
+ Element servlet = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
+ String servletClass = getElementContent(getOptionalChild(servlet, "servlet-class"));
+ if (servletClass != null)
+ {
+ servletClassNames.put(servletName, servletClass);
+ }
+
+ Iterator initParams = getChildrenByTagName(servlet, "init-param");
+ while (initParams.hasNext())
+ {
+ Element param = (Element) initParams.next();
+ String paramName = getElementContent(getUniqueChild(param, "param-name"));
+ String paramValue = getElementContent(getUniqueChild(param, "param-value"));
+
+ if (null == servletParams.get(servletName))
+ {
+ servletParams.put(servletName, new HashMap());
+ }
+
+ ((Map) servletParams.get(servletName)).put(paramName, paramValue);
+ }
+
+ Iterator roleRefs = getChildrenByTagName(servlet, "security-role-ref");
+ ArrayList roleNames = new ArrayList();
+ while (roleRefs.hasNext())
+ {
+ Element roleRefElem = (Element) roleRefs.next();
+ SecurityRoleRefMetaData roleRef = new SecurityRoleRefMetaData();
+ roleRef.importEjbJarXml(roleRefElem);
+ roleNames.add(roleRef);
+ }
+ securityRoleReferences.put(servletName, roleNames);
+
+ // Check for a run-as/role-name
+ Element runAs = getOptionalChild(servlet, "run-as");
+ if (runAs != null)
+ {
+ String runAsName = getElementContent(getOptionalChild(runAs, "role-name"));
+ runAsNames.put(servletName, runAsName);
+ }
+ }
+
+ // Parse the web-app/context-param elements
+ iterator = getChildrenByTagName(webApp, "context-param");
+ while (iterator.hasNext())
+ {
+ Element contextParam = (Element) iterator.next();
+ String paramName = getElementContent(getUniqueChild(contextParam, "param-name"));
+ String paramValue = getElementContent(getUniqueChild(contextParam, "param-value"));
+ contextParams.put(paramName, paramValue);
+ }
+
+ // Parse the web-app/servlet-mapping elements
+ iterator = getChildrenByTagName(webApp, "servlet-mapping");
+ while (iterator.hasNext())
+ {
+ Element servletMapping = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servletMapping, "servlet-name"));
+ String urlPattern = getElementContent(getUniqueChild(servletMapping, "url-pattern"));
+ servletMappings.put(servletName, urlPattern);
+ }
+
+ // Parse the web-app/resource-ref elements
+ iterator = getChildrenByTagName(webApp, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+ resourceReferences.put(resourceRefMetaData.getRefName(), resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = getChildrenByTagName(webApp, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // set the message destination references
+ iterator = getChildrenByTagName(webApp, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element) iterator.next();
+ MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
+ messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
+ messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
+ }
+
+ // set the message destinations (optional)
+ iterator = getChildrenByTagName(webApp, "message-destination");
+ while (iterator.hasNext())
+ {
+ Element messageDestination = (Element) iterator.next();
+ try
+ {
+ MessageDestinationMetaData messageDestinationMetaData = new MessageDestinationMetaData();
+ messageDestinationMetaData.importEjbJarXml(messageDestination);
+ messageDestinations.put(messageDestinationMetaData.getName(), messageDestinationMetaData);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
+ }
+ }
+
+ // Parse the web-app/env-entry elements
+ iterator = getChildrenByTagName(webApp, "env-entry");
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element) iterator.next();
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // Get the security-constraints
+ iterator = getChildrenByTagName(webApp, "security-constraint");
+ while (iterator.hasNext())
+ {
+ Element contraints = (Element) iterator.next();
+ WebSecurityMetaData wsmd = new WebSecurityMetaData();
+ securityContraints.add(wsmd);
+ // Process the web-resource-collections
+ Iterator iter2 = getChildrenByTagName(contraints, "web-resource-collection");
+ while (iter2.hasNext())
+ {
+ Element wrcElement = (Element) iter2.next();
+ Element wrName = getUniqueChild(wrcElement, "web-resource-name");
+ String name = getElementContent(wrName);
+ WebSecurityMetaData.WebResourceCollection wrc = wsmd.addWebResource(name);
+ Iterator iter21 = getChildrenByTagName(wrcElement, "url-pattern");
+ while (iter21.hasNext())
+ {
+ Element urlPattern = (Element) iter21.next();
+ String pattern = getElementContent(urlPattern);
+ wrc.addPattern(pattern);
+ }
+
+ Iterator iter22 = getChildrenByTagName(wrcElement, "http-method");
+ while (iter22.hasNext())
+ {
+ Element httpMethod = (Element) iter22.next();
+ String method = getElementContent(httpMethod);
+ wrc.addHttpMethod(method);
+ }
+ }
+
+ // Process the auth-constraints
+ Element authContraint = getOptionalChild(contraints, "auth-constraint");
+ if (authContraint != null)
+ {
+ Iterator iter3 = getChildrenByTagName(authContraint, "role-name");
+ while (iter3.hasNext())
+ {
+ Element roleName = (Element) iter3.next();
+ String name = getElementContent(roleName);
+ wsmd.addRole(name);
+ }
+ if (wsmd.getRoles().size() == 0)
+ wsmd.setExcluded(true);
+ }
+ else
+ {
+ wsmd.setUnchecked(true);
+ }
+
+ // Process the user-data-constraint
+ Element userData = getOptionalChild(contraints, "user-data-constraint");
+ if (userData != null)
+ {
+ Element transport = getUniqueChild(userData, "transport-guarantee");
+ String type = getElementContent(transport);
+ wsmd.setTransportGuarantee(type);
+ }
+ }
+
+ // Get the web-app/security-role elements (optional)
+ iterator = getChildrenByTagName(webApp, "security-role");
+ while (iterator.hasNext())
+ {
+ Element securityRole = (Element) iterator.next();
+ String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
+ securityRoles.put(roleName, new SecurityRoleMetaData(roleName));
+ }
+
+ // Parse the web-app/ejb-ref elements
+ iterator = getChildrenByTagName(webApp, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the web-app/ejb-local-ref elements
+ iterator = getChildrenByTagName(webApp, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ EjbLocalRefMetaData ejbRefMetaData = new EjbLocalRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+ ejbLocalReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(webApp, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // Is the web-app marked distributable?
+ iterator = getChildrenByTagName(webApp, "distributable");
+ if (iterator.hasNext())
+ {
+ distributable = true;
+ }
+ }
+
+ /** Parse the elements of the jboss-web element used by the integration layer.
+ */
+ protected void importJBossWebXml(Element jbossWeb) throws DeploymentException
+ {
+ // Parse the jboss-web/root-context element
+ Element contextRootElement = getOptionalChild(jbossWeb, "context-root");
+ if (contextRootElement != null)
+ contextRoot = getElementContent(contextRootElement);
+
+ // Parse the jboss-web/security-domain element
+ Element securityDomainElement = getOptionalChild(jbossWeb, "security-domain");
+ if (securityDomainElement != null)
+ {
+ securityDomain = getElementContent(securityDomainElement);
+ // Check the flushOnSessionInvalidation attribute
+ Boolean flag = Boolean.valueOf(securityDomainElement.getAttribute("flushOnSessionInvalidation"));
+ flushOnSessionInvalidation = flag.booleanValue();
+ }
+
+ //Parse the jboss-web/jacc-star-role-allow element
+ Element jaccStarRoleElement = getOptionalChild(jbossWeb, "jacc-star-role-allow");
+ if (jaccStarRoleElement != null)
+ {
+ jaccRoleNameStar = "true".equalsIgnoreCase(getElementContent(jaccStarRoleElement));
+ }
+
+ // Parse the jboss-web/virtual-host elements
+ for (Iterator virtualHostElements = getChildrenByTagName(jbossWeb, "virtual-host"); virtualHostElements.hasNext();)
+ {
+ Element virtualHostElement = (Element) virtualHostElements.next();
+ String virtualHostName = getElementContent(virtualHostElement);
+ virtualHosts.add(virtualHostName);
+ } // end of for ()
+
+ // Parse the jboss-web/resource-ref elements
+ Iterator iterator = getChildrenByTagName(jbossWeb, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // Parse the jboss-web/resource-env-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // update the message destination references (optional)
+ iterator = getChildrenByTagName(jbossWeb, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element) iterator.next();
+ String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef,
+ "message-destination-ref-name"));
+ MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences
+ .get(messageDestinationRefName);
+ if (messageDestinationRefMetaData == null)
+ throw new DeploymentException("message-destination-ref " + messageDestinationRefName
+ + " found in jboss-web.xml but not in web.xml");
+ messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
+ }
+
+ // set the message destinations (optional)
+ iterator = getChildrenByTagName(jbossWeb, "message-destination");
+ while (iterator.hasNext())
+ {
+ Element messageDestination = (Element) iterator.next();
+ try
+ {
+ String messageDestinationName = getUniqueChildContent(messageDestination, "message-destination-name");
+ MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations
+ .get(messageDestinationName);
+ if (messageDestinationMetaData == null)
+ throw new DeploymentException("message-destination " + messageDestinationName
+ + " found in jboss-web.xml but not in web.xml");
+ messageDestinationMetaData.importJbossXml(messageDestination);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
+ }
+ }
+
+ // set the security roles (optional)
+ iterator = getChildrenByTagName(jbossWeb, "security-role");
+ while (iterator.hasNext())
+ {
+ Element securityRole = (Element) iterator.next();
+ String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
+ SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
+ if (securityRoleMetaData == null)
+ throw new DeploymentException("Security role '" + roleName + "' defined in jboss-web.xml"
+ + " is not defined in web.xml");
+
+ Iterator itPrincipalNames = getChildrenByTagName(securityRole, "principal-name");
+ while (itPrincipalNames.hasNext())
+ {
+ String principalName = getElementContent((Element) itPrincipalNames.next());
+ securityRoleMetaData.addPrincipalName(principalName);
+ }
+ }
+
+ // Parse the jboss-web/ejb-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss-web.xml but not in web.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+ // Parse the jboss-web/ejb-local-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element) iterator.next();
+ String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
+ EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences.get(ejbLocalRefName);
+ if (ejbLocalRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ejbLocalRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(jbossWeb, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData) serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // WebserviceDescriptions
+ iterator = getChildrenByTagName(jbossWeb, "webservice-description");
+ while (iterator.hasNext())
+ {
+ Element wsd = (Element) iterator.next();
+ String wsdName = getElementContent(getUniqueChild(wsd, "webservice-description-name"));
+ configName = MetaData.getOptionalChildContent(wsd, "config-name");
+ configFile = MetaData.getOptionalChildContent(wsd, "config-file");
+ String wsdlPublishLocation = getOptionalChildContent(wsd, "wsdl-publish-location");
+ wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation);
+ }
+
+ // Parse the jboss-web/depends elements
+ for (Iterator dependsElements = getChildrenByTagName(jbossWeb, "depends"); dependsElements.hasNext();)
+ {
+ Element dependsElement = (Element) dependsElements.next();
+ String dependsName = getElementContent(dependsElement);
+ depends.add(ObjectNameFactory.create(dependsName));
+ } // end of for ()
+
+ // Parse the jboss-web/use-session-cookies element
+ iterator = getChildrenByTagName(jbossWeb, "use-session-cookies");
+ if (iterator.hasNext())
+ {
+ Element useCookiesElement = (Element) iterator.next();
+ String useCookiesElementContent = getElementContent(useCookiesElement);
+ Boolean useCookies = Boolean.valueOf(useCookiesElementContent);
+
+ if (useCookies.booleanValue())
+ {
+ sessionCookies = SESSION_COOKIES_ENABLED;
+ }
+ else
+ {
+ sessionCookies = SESSION_COOKIES_DISABLED;
+ }
+ }
+
+ // Parse the jboss-web/session-replication element
+
+ Element sessionReplicationRootElement = getOptionalChild(jbossWeb, "replication-config");
+ if (sessionReplicationRootElement != null)
+ {
+ // manage "replication-trigger" first ...
+ //
+ Element replicationTriggerElement = getOptionalChild(sessionReplicationRootElement, "replication-trigger");
+ if (replicationTriggerElement != null)
+ {
+ String repMethod = getElementContent(replicationTriggerElement);
+ if ("SET_AND_GET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET;
+ else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
+ else if ("SET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET;
+ else
+ throw new DeploymentException("replication-trigger value set to a non-valid value: '" + repMethod
+ + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml");
+ }
+
+ // ... then manage "replication-type".
+ //
+ Element replicationTypeElement = getOptionalChild(sessionReplicationRootElement, "replication-type");
+ if (replicationTypeElement != null)
+ {
+ String repType = getElementContent(replicationTypeElement);
+ if ("SYNC".equalsIgnoreCase(repType))
+ this.replicationType = REPLICATION_TYPE_SYNC;
+ else if ("ASYNC".equalsIgnoreCase(repType))
+ this.replicationType = REPLICATION_TYPE_ASYNC;
+ else
+ throw new DeploymentException("replication-type value set to a non-valid value: '" + repType
+ + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml");
+ }
+
+ // ... then manage "replication-type".
+ //
+ Element replicationGranularityElement = MetaData.getOptionalChild(sessionReplicationRootElement,
+ "replication-granularity");
+ if (replicationGranularityElement != null)
+ {
+ String repType = MetaData.getElementContent(replicationGranularityElement);
+ if ("SESSION".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_SESSION;
+ else if ("ATTRIBUTE".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE;
+ else if ("FIELD".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_FIELD;
+ else
+ throw new DeploymentException("replication-granularity value set to a non-valid value: '" + repType
+ + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml");
+ }
+
+ Element batchModeElement = MetaData.getOptionalChild(sessionReplicationRootElement,
+ "replication-field-batch-mode");
+ if (batchModeElement != null)
+ {
+ Boolean flag = Boolean.valueOf(MetaData.getElementContent(batchModeElement));
+ replicationFieldBatchMode = flag.booleanValue();
+ }
+ }
+
+ // Check for a war level class loading config
+ Element classLoading = MetaData.getOptionalChild(jbossWeb, "class-loading");
+ if (classLoading != null)
+ {
+ String flagString = classLoading.getAttribute("java2ClassLoadingCompliance");
+ if (flagString.length() == 0)
+ flagString = "true";
+ boolean flag = Boolean.valueOf(flagString).booleanValue();
+ setJava2ClassLoadingCompliance(flag);
+ // Check for a loader-repository for scoping
+ Element loader = MetaData.getOptionalChild(classLoading, "loader-repository");
+ if (loader != null)
+ {
+ useJBossWebLoader = true;
+ try
+ {
+ loaderConfig = LoaderRepositoryFactory.parseRepositoryConfig(loader);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+ }
+
+ // Parse the jboss-web/servlet elements
+ iterator = getChildrenByTagName(jbossWeb, "servlet");
+ while (iterator.hasNext())
+ {
+ Element servlet = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
+ String principalName = getOptionalChildContent(servlet, "run-as-principal");
+ // Get the web.xml run-as primary role
+ String webXmlRunAs = (String) runAsNames.get(servletName);
+ if (principalName != null)
+ {
+ if (webXmlRunAs == null)
+ {
+ throw new DeploymentException("run-as-principal: " + principalName
+ + " found in jboss-web.xml but there was no run-as in web.xml");
+ }
+ // See if there are any additional roles for this principal
+ Set extraRoles = getSecurityRoleNamesByPrincipal(principalName);
+ RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, principalName, extraRoles);
+ runAsIdentity.put(servletName, runAs);
+ }
+ else if (webXmlRunAs != null)
+ {
+ RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, null);
+ runAsIdentity.put(servletName, runAs);
+ }
+ }
+
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.serviceref;
+
+// $Id: ServiceRefDelegate.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.soap.FactoryLoader;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.logging.Logger;
+import org.jboss.ws.integration.UnifiedVirtualFile;
+import org.jboss.ws.integration.ServiceRefElement;
+import org.jboss.ws.integration.ServiceRefHandler;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.jboss.ws.integration.KernelLocator;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+
+/**
+ * Factory for ServiceRefHandler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 05-May-2004
+ */
+public class ServiceRefDelegate implements ServiceRefHandler
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(ServiceRefDelegate.class);
+
+ private static ServiceRefHandler delegate;
+
+ public ServiceRefDelegate()
+ {
+ if (delegate == null)
+ {
+ Kernel kernel = KernelLocator.getKernel();
+ if (kernel != null)
+ {
+ KernelRegistry registry = kernel.getRegistry();
+ KernelRegistryEntry entry = registry.getEntry(ServiceRefHandler.BEAN_NAME);
+ delegate = (ServiceRefHandler)entry.getTarget();
+ }
+ else
+ {
+ String propName = ServiceRefHandler.class.getName();
+ String defaultImpl = "org.jboss.ws.core.client.ServiceRefHandlerImpl";
+ delegate = (ServiceRefHandler)FactoryLoader.loadFactory(propName, defaultImpl);
+ }
+ }
+
+ if (delegate == null)
+ log.warn("Not registered: " + ServiceRefHandler.BEAN_NAME);
+ }
+
+ public ServiceRefMetaData newServiceRefMetaData()
+ {
+ ServiceRefMetaData sref;
+ if (delegate != null)
+ sref = delegate.newServiceRefMetaData();
+ else
+ sref = new DummyServiceRef();
+ return sref;
+ }
+
+ public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ if (delegate != null)
+ child = delegate.newChild(ref, navigator, namespaceURI, localName, attrs);
+ return child;
+ }
+
+ public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (delegate != null)
+ delegate.setValue(ref, navigator, namespaceURI, localName, value);
+ }
+
+ public void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader, ServiceRefMetaData sref) throws NamingException
+ {
+ if (delegate != null)
+ delegate.bindServiceRef(encCtx, encName, vfsRoot, loader, sref);
+ }
+
+ public static class DummyServiceRef extends ServiceRefMetaData
+ {
+ private String refName;
+
+ @Override
+ public void setServiceRefName(String name)
+ {
+ this.refName = name;
+ }
+
+ @Override
+ public String getServiceRefName()
+ {
+ return refName;
+ }
+
+ @Override
+ public Object getAnnotatedElement()
+ {
+ return null;
+ }
+
+ @Override
+ public void setAnnotatedElement(Object anElement)
+ {
+ }
+
+ @Override
+ public void importJBossXml(Element element)
+ {
+ }
+
+ @Override
+ public void importStandardXml(Element element)
+ {
+ }
+
+ @Override
+ public boolean isProcessed()
+ {
+ return false;
+ }
+
+ @Override
+ public void setProcessed(boolean flag)
+ {
+ }
+
+ @Override
+ public void merge(ServiceRefMetaData serviceRef)
+ {
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.serviceref;
+
+// $Id: ServiceRefObjectFactory.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.integration.ServiceRefElement;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+
+/**
+ * A object model factory for <service-ref>
+ *
+ * @author Thomas.Diesler at jboss.com
+ */
+public abstract class ServiceRefObjectFactory implements ObjectModelFactory
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(ServiceRefObjectFactory.class);
+
+
+ public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return new ServiceRefDelegate().newChild(ref, navigator, namespaceURI, localName, attrs);
+ }
+
+ public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ new ServiceRefDelegate().setValue(ref, navigator, namespaceURI, localName, value);
+ }
+
+ public static boolean isJ2EE14Descriptor(Element element)
+ {
+ // Verify J2EE-1.4
+ String nsURI = element.getOwnerDocument().getDocumentElement().getNamespaceURI();
+ boolean isValid = "http://java.sun.com/xml/ns/j2ee".equals(nsURI);
+
+ // Verify JBoss-4.0
+ DocumentType doctype = element.getOwnerDocument().getDoctype();
+ if (isValid == false && doctype != null)
+ {
+ String publicId = doctype.getPublicId();
+ isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD JBOSS 4.2//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Web Application 2.4//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Application Client 4.2//EN".equals(publicId);
+ }
+
+ if (isValid == false)
+ {
+ String dtstr = (doctype != null ? "[public=" + doctype.getPublicId() + ",system=" + doctype.getSystemId() + "]" : null);
+ log.debug("Skip <service-ref> for: nsURI=" + nsURI + ",doctype=" + dtstr);
+ }
+ return isValid;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/web/AbstractWebDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/web/AbstractWebDeployer.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/42specific/org/jboss/web/AbstractWebDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,885 @@
+/*
+ * 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.web;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployment.J2eeApplicationMetaData;
+import org.jboss.ejb.Container;
+import org.jboss.ejb.EjbUtil;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.EjbLocalRefMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.MessageDestinationMetaData;
+import org.jboss.metadata.MessageDestinationRefMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
+import org.jboss.ws.integration.URLLoaderAdapter;
+import org.jboss.ws.integration.UnifiedVirtualFile;
+import org.jboss.ws.integration.ServiceRefMetaData;
+import org.omg.CORBA.ORB;
+
+/** A template pattern class for web deployer integration into JBoss. This class
+should be subclasses by war deployers providers wishing to integrate into
+a JBoss server.
+
+It provides support for mapping the following web-app.xml/jboss-web.xml elements
+into the JBoss server JNDI namespace:
+- env-entry
+- resource-ref
+- resource-env-ref
+- ejb-ref
+- ejb-local-ref
+- security-domain
+
+Subclasses need to implement the {@link #performDeploy(WebApplication, String,
+ WebDescriptorParser) performDeploy()}
+and {@link #performUndeploy(String, WebApplication) performUndeploy()} methods to perform the
+container specific steps and return the web application info required by the
+AbstractWebContainer class.
+
+Integration with the JBossSX security framework is based on the establishment
+of a java:comp/env/security context as described in the
+{@link #linkSecurityDomain(String,Context) linkSecurityDomain } comments.
+The security context provides access to the JBossSX security mgr interface
+implementations for use by subclass request interceptors. A outline of the
+steps for authenticating a user is:
+<code>
+ // Get the username & password from the request context...
+ String username = f(request);
+ String password = f(request);
+ // Get the JBoss security manager from the ENC context
+ InitialContext iniCtx = new InitialContext();
+ SecurityManager securityMgr = (SecurityManager) iniCtx.lookup("java:comp/env/security/securityMgr");
+ SimplePrincipal principal = new SimplePrincipal(username);
+ if( securityMgr.isValid(principal, password) )
+ {
+ // Indicate the user is allowed access to the web content...
+
+ // Propagate the user info to JBoss for any calls into made by the servlet
+ SecurityAssociation.setPrincipal(principal);
+ SecurityAssociation.setCredential(password.toCharArray());
+ }
+ else
+ {
+ // Deny access...
+ }
+</code>
+
+An outline of the steps for authorizing the user is:
+<code>
+ // Get the username & required roles from the request context...
+ String username = f(request);
+ String[] roles = f(request);
+ // Get the JBoss security manager from the ENC context
+ InitialContext iniCtx = new InitialContext();
+ RealmMapping securityMgr = (RealmMapping) iniCtx.lookup("java:comp/env/security/realmMapping");
+ SimplePrincipal principal = new SimplePrincipal(username);
+ Set requiredRoles = new HashSet(Arrays.asList(roles));
+ if( securityMgr.doesUserHaveRole(principal, requiredRoles) )
+ {
+ // Indicate the user has the required roles for the web content...
+ }
+ else
+ {
+ // Deny access...
+ }
+</code>
+
+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. If your adapting a web container that is trying be compatible with
+both 1.1 and 1.2 Java VMs this is something you need to pay special attention
+to. For example, I have seen problems a request interceptor that was handling
+the authentication/authorization callouts in tomcat3.2.1 not having the same
+thread context ClassLoader as was used to dispatch the http service request.
+
+ at see #performDeploy(WebApplication webApp, String warUrl,
+ WebDescriptorParser webAppParser)
+ at see #performUndeploy(String, WebApplication)
+ at see #parseWebAppDescriptors(DeploymentInfo,ClassLoader, WebMetaData)
+ at see #linkSecurityDomain(String, Context)
+ at see org.jboss.security.RealmMapping;
+ at see org.jboss.security.SimplePrincipal;
+ at see org.jboss.security.SecurityAssociation;
+
+ at jmx.mbean
+ name="jboss.web:service=WebServer"
+ extends="org.jboss.deployment.SubDeployerMBean"
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 69712 $
+*/
+public abstract class AbstractWebDeployer
+{
+ public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+ protected Logger log;
+
+ protected MBeanServer server;
+ /** 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;
+
+ public AbstractWebDeployer()
+ {
+ log = Logger.getLogger(getClass());
+ }
+
+ public abstract void init(Object containerConfig) throws Exception;
+
+ public MBeanServer getServer()
+ {
+ return server;
+ }
+ public void setServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ /** 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 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()
+ {
+ 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;
+ }
+
+ /** 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
+ webAppParser.parseWebAppDescriptors(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 di 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(DeploymentInfo di) throws DeploymentException
+ {
+ Thread thread = Thread.currentThread();
+ ClassLoader appClassLoader = thread.getContextClassLoader();
+ WebApplication warInfo = null;
+ try
+ {
+ // Create a classloader for the war to ensure a unique ENC
+ URL[] empty = {};
+ URLClassLoader warLoader = URLClassLoader.newInstance(empty, di.ucl);
+ thread.setContextClassLoader(warLoader);
+ WebDescriptorParser webAppParser = new DescriptorParser(di);
+ String webContext = di.webContext;
+ if (webContext != null && webContext.startsWith("/") == false)
+ webContext = "/" + webContext;
+
+ // Get the war URL
+ URL warURL = di.localUrl != null ? di.localUrl : di.url;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("webContext: " + webContext);
+ log.debug("warURL: " + warURL);
+ log.debug("webAppParser: " + webAppParser);
+ }
+
+ // Get the web.xml and jboss-web.xml descriptor metadata
+ WebMetaData webMetaData = (WebMetaData) di.metaData;
+
+ // inherit the security setup from jboss-app.xml
+ if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
+ {
+ J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData)di.parent.metaData;
+
+ if (webMetaData.getSecurityDomain() == null)
+ webMetaData.setSecurityDomain(appMetaData.getSecurityDomain());
+
+ webMetaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
+ }
+
+ // Register the permissions with the JACC layer
+ String contextID = di.shortName;
+ if( contextID == null )
+ contextID = di.shortName;
+ webMetaData.setJaccContextID(contextID);
+ PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ createPermissions(webMetaData, pc);
+ // Link this to the parent PC
+ DeploymentInfo current = di;
+ while( current.parent != null )
+ current = current.parent;
+ PolicyConfiguration parentPC = (PolicyConfiguration)
+ current.context.get("javax.security.jacc.PolicyConfiguration");
+ if( parentPC != null && parentPC != pc )
+ parentPC.linkConfiguration(pc);
+
+ // Commit the policy configuration
+ pc.commit();
+ // Allow the policy to incorporate the policy configs
+ Policy.getPolicy().refresh();
+
+ warInfo = new WebApplication(webMetaData);
+ warInfo.setDeploymentInfo(di);
+ warInfo.setClassLoader(warLoader);
+ performDeploy(warInfo, warURL.toString(), webAppParser);
+ }
+ catch(DeploymentException e)
+ {
+ di.context.put(ERROR, e);
+ throw e;
+ }
+ catch(Exception e)
+ {
+ DeploymentException ex = new DeploymentException("Error during deploy", e);
+ di.context.put(ERROR, ex);
+ throw ex;
+ }
+ finally
+ {
+ thread.setContextClassLoader(appClassLoader);
+ }
+ return warInfo;
+ }
+
+ /** This method is called by the deploy() 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.
+ @param webAppParser The callback interface the web container should use to
+ setup the web app JNDI environment for use by the web app components. This
+ needs to be invoked after the web app class loader is known, but before
+ and web app components attempt to access the java:comp/env JNDI namespace.
+ */
+ protected abstract void performDeploy(WebApplication webApp, String warUrl,
+ WebDescriptorParser webAppParser) throws Exception;
+
+ /** 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(DeploymentInfo di)
+ throws DeploymentException
+ {
+ URL warURL = di.localUrl != null ? di.localUrl : di.url;
+ String warUrl = warURL.toString();
+ try
+ {
+ WebApplication webApp = (WebApplication) di.context.get(AbstractWebContainer.WEB_APP);
+ performUndeploy(warUrl, webApp);
+ // Unegister the permissions with the JACC layer
+ WebMetaData webMetaData = (WebMetaData) di.metaData;
+ String contextID = webMetaData.getJaccContextID();
+ PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ pc.delete();
+ }
+ catch(DeploymentException e)
+ {
+ throw e;
+ }
+ catch(Exception e)
+ {
+ throw new DeploymentException("Error during deploy", e);
+ }
+ }
+
+ /** Called as part of the undeploy() method template to ask the
+ subclass for perform the web container specific undeployment steps.
+ */
+ protected abstract void performUndeploy(String warUrl, WebApplication webApp)
+ 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 parseWebAppDescriptors(DeploymentInfo di, ClassLoader loader,
+ WebMetaData metaData)
+ throws Exception
+ {
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
+ InitialContext iniCtx = new InitialContext();
+ Context envCtx = null;
+ Thread currentThread = Thread.currentThread();
+ ClassLoader currentLoader = currentThread.getContextClassLoader();
+ 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: Where does this ENC get tidied up?
+ currentThread.setContextClassLoader(loader);
+ metaData.setENCLoader(loader);
+ envCtx = (Context) iniCtx.lookup("java:comp");
+
+ ORB orb = null;
+ try
+ {
+ orb = (ORB) server.getAttribute(Container.ORB_NAME, "ORB");
+ }
+ catch (Throwable t)
+ {
+ log.debug("Unable to retrieve orb" + t.toString());
+ }
+
+ // Bind the orb
+ if (orb != null)
+ {
+ NonSerializableFactory.rebind(envCtx, "ORB", orb);
+ log.debug("Bound java:comp/ORB");
+ }
+
+ // 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");
+ }
+ finally
+ {
+ currentThread.setContextClassLoader(currentLoader);
+ }
+
+ Iterator envEntries = metaData.getEnvironmentEntries();
+ log.debug("addEnvEntries");
+ addEnvEntries(envEntries, envCtx);
+ Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
+ log.debug("linkResourceEnvRefs");
+ linkResourceEnvRefs(resourceEnvRefs, envCtx);
+ Iterator resourceRefs = metaData.getResourceReferences();
+ log.debug("linkResourceRefs");
+ linkResourceRefs(resourceRefs, envCtx);
+ log.debug("linkMessageDestinationRefs");
+ linkMessageDestinationRefs(metaData, envCtx, di);
+ Iterator ejbRefs = metaData.getEjbReferences();
+ log.debug("linkEjbRefs");
+ linkEjbRefs(ejbRefs, envCtx, di);
+ Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
+ log.debug("linkEjbLocalRefs");
+ linkEjbLocalRefs(ejbLocalRefs, envCtx, di);
+ log.debug("linkServiceRefs");
+ linkServiceRefs(metaData, envCtx, di);
+ String securityDomain = metaData.getSecurityDomain();
+ log.debug("linkSecurityDomain");
+ linkSecurityDomain(securityDomain, envCtx);
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
+ }
+
+ private void linkServiceRefs(WebMetaData metaData, Context envCtx, DeploymentInfo di) throws NamingException
+ {
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+ }
+
+ protected void addEnvEntries(Iterator envEntries, Context envCtx)
+ throws ClassNotFoundException, NamingException
+ {
+ while( envEntries.hasNext() )
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData) envEntries.next();
+ log.debug("Binding env-entry: "+entry.getName()+" of type: " +
+ entry.getType()+" to value:"+entry.getValue());
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+ }
+
+ protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceEnvRefs.hasNext() )
+ {
+ ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData) resourceEnvRefs.next();
+ String resourceName = ref.getJndiName();
+ String refName = ref.getRefName();
+ 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(Iterator resourceRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceRefs.hasNext() )
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
+ String jndiName = ref.getJndiName();
+ String refName = ref.getRefName();
+ if( ref.getType().equals("java.net.URL") )
+ {
+ try
+ {
+ String resURL = ref.getResURL();
+ if( ref.getResURL() != 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(WebMetaData metaData, Context envCtx, DeploymentInfo di)
+ throws NamingException, DeploymentException
+ {
+ Iterator i = metaData.getMessageDestinationReferences();
+
+ while (i.hasNext())
+ {
+ MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
+
+ String refName = ref.getRefName();
+ String jndiName = ref.getJNDIName();
+ String link = ref.getLink();
+ if (link != null)
+ {
+ if (jndiName == null)
+ {
+ MessageDestinationMetaData messageDestination = EjbUtil.findMessageDestination(server, di, link);
+ if (messageDestination == null)
+ throw new DeploymentException("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 DeploymentException("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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
+ throws NamingException
+ {
+ while( ejbRefs.hasNext() )
+ {
+ EjbRefMetaData ejb = (EjbRefMetaData) ejbRefs.next();
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use ejb-link if it is specified
+ if ( linkName != null )
+ {
+ jndiName = EjbUtil.findEjbLink(server, di, 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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
+ throws NamingException
+ {
+ while( ejbRefs.hasNext() )
+ {
+ EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use the ejb-link field if it is specified
+ if ( linkName != null )
+ {
+ jndiName = EjbUtil.findLocalEjbLink(server, di, 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);
+ }
+ 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));
+ 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 = AbstractWebContainer.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());
+ }
+ }
+
+ /** Create the JACC permission based on the security constraints obtained
+ * from the web.xml metadata.
+ *
+ * @param metaData
+ * @param pc
+ * @throws PolicyContextException
+ */
+ protected void createPermissions(WebMetaData metaData, PolicyConfiguration pc)
+ throws PolicyContextException
+ {
+ WebPermissionMapping.createPermissions(metaData, pc);
+ }
+
+ /** An inner class that maps the WebDescriptorParser.parseWebAppDescriptors()
+ onto the protected parseWebAppDescriptors() AbstractWebContainer method.
+ */
+ private class DescriptorParser implements WebDescriptorParser
+ {
+ DeploymentInfo di;
+ DescriptorParser(DeploymentInfo di)
+ {
+ this.di = di;
+ }
+ public void parseWebAppDescriptors(ClassLoader loader, WebMetaData metaData)
+ throws Exception
+ {
+ AbstractWebDeployer.this.parseWebAppDescriptors(di, loader, metaData);
+ }
+ public DeploymentInfo getDeploymentInfo()
+ {
+ return di;
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/ClientDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/ClientDeployer.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/ClientDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,332 @@
+/*
+ * 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.deployment;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+
+import org.jboss.ejb.EjbUtil;
+import org.jboss.metadata.ClientMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.XmlFileLoader;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.common.URLLoaderAdapter;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+/**
+ * An XMBean resource implementation of a deployer for j2ee application
+ * client jars
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 69712 $
+ */
+public class ClientDeployer extends SubDeployerSupport
+{
+ protected void startService() throws Exception
+ {
+ // register with MainDeployer
+ super.startService();
+ }
+
+ /**
+ * Implements the template method in superclass. This method stops all the
+ * applications in this server.
+ */
+ protected void stopService() throws Exception
+ {
+ // deregister with MainDeployer
+ super.stopService();
+ }
+
+ /**
+ * This method looks to the deployment for a META-INF/application-client.xml
+ * descriptor to identify a j2ee client jar.
+ *
+ * @param di The deployment info instance for the jar
+ * @return true if the deployment is a j2ee client jar, false otherwise
+ */
+ public boolean accepts(DeploymentInfo di)
+ {
+ // To be accepted the deployment's root name must end in jar
+ String urlStr = di.url.getFile();
+ if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".jar/"))
+ {
+ return false;
+ }
+
+ // However the jar must also contain an META-INF/application-client.xml
+ boolean accepts = false;
+ try
+ {
+ URL dd = di.localCl.findResource("META-INF/application-client.xml");
+ if (dd != null)
+ {
+ log.debug("Found a META-INF/application-client.xml file, di: " + di);
+ accepts = true;
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ return accepts;
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'create' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.CREATE_NOTIFICATION.
+ */
+ public void create(DeploymentInfo di) throws DeploymentException
+ {
+ super.create(di);
+ }
+
+ /**
+ * Parse the application-client.xml and jboss-client.xml descriptors.
+ *
+ * @param di the application client jar deployment info
+ */
+ public void start(DeploymentInfo di) throws DeploymentException
+ {
+ ClientMetaData metaData = null;
+ try
+ {
+ InputStream in = null;
+ if (di.alternativeDD == null)
+ {
+ in = di.localCl.getResourceAsStream("META-INF/application-client.xml");
+ }
+ else
+ {
+ String contentsDir = new File(di.url.getPath()).getParent();
+ in = new FileInputStream(contentsDir + "/" + di.alternativeDD);
+ }
+
+ if (in == null)
+ throw new DeploymentException("No META-INF/application-client.xml found");
+
+ metaData = null;
+ XmlFileLoader xfl = new XmlFileLoader(true);
+ Element appClient = xfl.getDocument(in, "META-INF/application-client.xml").getDocumentElement();
+ in.close();
+ metaData = new ClientMetaData();
+ metaData.setResourceClassLoader(di.localCl);
+ metaData.importClientXml(appClient);
+ di.metaData = metaData;
+
+ // Look for a jboss-client.xml descriptor
+ in = di.localCl.getResourceAsStream("META-INF/jboss-client.xml");
+ if (in != null)
+ {
+ xfl = new XmlFileLoader(true);
+ Element jbossClient = xfl.getDocument(in, "META-INF/jboss-client.xml").getDocumentElement();
+ in.close();
+ metaData.importJbossClientXml(jbossClient);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new DeploymentException("Failed to parse metadata", e);
+ }
+
+ try
+ {
+ setupEnvironment(di, metaData);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Failed to setup client ENC", e);
+ }
+
+ super.start(di);
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'stop' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.
+ */
+ public void stop(DeploymentInfo di) throws DeploymentException
+ {
+ // Teardown the JNDI context
+ ClientMetaData metaData = (ClientMetaData) di.metaData;
+ if (metaData != null)
+ {
+ String appClientName = metaData.getJndiName();
+ log.info("Removing client ENC from: " + appClientName);
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ Util.unbind(iniCtx, appClientName);
+ }
+ catch (NamingException e)
+ {
+ throw new DeploymentException("Failed to remove client ENC", e);
+ }
+ }
+ super.stop(di);
+ }
+
+ /**
+ * Sub-classes should override this method to provide
+ * custom 'destroy' logic.
+ * <p/>
+ * This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION.
+ */
+ public void destroy(DeploymentInfo di) throws DeploymentException
+ {
+ super.destroy(di);
+ }
+
+ private void setupEnvironment(DeploymentInfo di, ClientMetaData metaData)
+ throws Exception
+ {
+ // Setup a JNDI context which contains
+ String appClientName = metaData.getJndiName();
+ InitialContext iniCtx = new InitialContext();
+ Context envCtx = Util.createSubcontext(iniCtx, appClientName);
+ log.debug("Creating client ENC binding under: " + appClientName);
+ // Bind environment properties
+ Iterator i = metaData.getEnvironmentEntries().iterator();
+ while (i.hasNext())
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData) i.next();
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+ entry.getType() + " to value:" + entry.getValue());
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+
+ // Bind EJB references
+ HashMap ejbRefs = metaData.getEjbReferences();
+ i = ejbRefs.values().iterator();
+ while (i.hasNext())
+ {
+ EjbRefMetaData ref = (EjbRefMetaData) i.next();
+ log.debug("Binding an EJBReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ String linkName = ref.getLink();
+ String jndiName = EjbUtil.findEjbLink(server, di, linkName);
+ log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName);
+ if (jndiName == null)
+ {
+ String msg = "Failed to resolve ejb-link: " + linkName
+ + " make by ejb-name: " + ref.getName();
+ throw new DeploymentException(msg);
+ }
+ log.debug("Link resolved to:" + jndiName);
+ Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
+ }
+ else
+ {
+ // Bind the bean level ejb-ref/jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or jndi-name in jboss.xml");
+ }
+ log.debug("Binding " + ref.getName() + " to : " + ref.getJndiName());
+ Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
+ }
+ }
+
+ // Bind service references
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+
+ // Bind resource references
+ HashMap resRefs = metaData.getResourceReferences();
+ i = resRefs.values().iterator();
+ while (i.hasNext())
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData) i.next();
+ String refName = ref.getRefName();
+ String jndiName = ref.getJndiName();
+
+ if (ref.getType().equals("java.net.URL"))
+ {
+ // URL bindings
+ 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);
+ }
+ }
+ else
+ {
+ // A resource link
+ log.debug("Binding resource: " + refName + " to JDNI as: " + jndiName);
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
+
+ // Bind resource env references
+ HashMap envRefs = metaData.getResourceEnvReferences();
+ i = envRefs.values().iterator();
+ while (i.hasNext())
+ {
+ ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData) i.next();
+ String encName = resRef.getRefName();
+ String jndiName = resRef.getJndiName();
+ // Should validate the type...
+ log.debug("Binding env resource: " + encName +
+ " to JDNI as: " + jndiName);
+ Util.bind(envCtx, encName, new LinkRef(jndiName));
+ }
+ log.info("Client ENC bound under: " + appClientName);
+ }
+}
+
Property changes on: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/deployment/ClientDeployer.java
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/ejb/Container.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/ejb/Container.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/ejb/Container.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1602 @@
+/*
+ * 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;
+
+// $Id: Container.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.rmi.MarshalException;
+import java.security.AccessController;
+import java.security.Policy;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBException;
+import javax.ejb.EJBObject;
+import javax.ejb.TimedObject;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.ejb.spi.HandleDelegate;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.transaction.TransactionManager;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.ejb.plugins.local.BaseLocalProxyFactory;
+import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.invocation.InvocationStatistics;
+import org.jboss.invocation.InvocationType;
+import org.jboss.invocation.JBossLazyUnmarshallingException;
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ApplicationMetaData;
+import org.jboss.metadata.BeanMetaData;
+import org.jboss.metadata.EjbLocalRefMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.MessageDestinationMetaData;
+import org.jboss.metadata.MessageDestinationRefMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.util.ObjectNameConverter;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.RealmMapping;
+import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.util.NestedError;
+import org.jboss.util.NestedRuntimeException;
+import org.jboss.util.naming.ENCThreadLocalKey;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.common.URLLoaderAdapter;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.omg.CORBA.ORB;
+
+/**
+ * This is the base class for all EJB-containers in JBoss. A Container
+ * functions as the central hub of all metadata and plugins. Through this
+ * the container plugins can get hold of the other plugins and any metadata
+ * they need.
+ *
+ * <p>The EJBDeployer creates instances of subclasses of this class
+ * and calls the appropriate initialization methods.
+ *
+ * <p>A Container does not perform any significant work, but instead delegates
+ * to the plugins to provide for all kinds of algorithmic functionality.
+ *
+ * @see EJBDeployer
+ *
+ * @author <a href="mailto:rickard.oberg at jboss.org">Rickard �berg</a>
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ * @author <a href="bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:christoph.jung at infor.de">Christoph G. Jung</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 69712 $
+ *
+ * @jmx.mbean extends="org.jboss.system.ServiceMBean"
+ */
+public abstract class Container extends ServiceMBeanSupport
+ implements ContainerMBean, AllowedOperationsFlags
+{
+ public final static String BASE_EJB_CONTAINER_NAME =
+ "jboss.j2ee:service=EJB";
+
+ public final static ObjectName ORB_NAME = ObjectNameFactory.create("jboss:service=CorbaORB");
+
+ public final static ObjectName EJB_CONTAINER_QUERY_NAME =
+ ObjectNameFactory.create(BASE_EJB_CONTAINER_NAME + ",*");
+
+ protected static final Method EJBOBJECT_REMOVE;
+ /** A reference to {@link javax.ejb.TimedObject#ejbTimeout}. */
+ protected static final Method EJB_TIMEOUT;
+
+ /** This is the application that this container is a part of */
+ protected EjbModule ejbModule;
+
+ /**
+ * This is the local classloader of this container. Used for loading
+ * resources that must come from the local jar file for the container.
+ * NOT for loading classes!
+ */
+ protected ClassLoader localClassLoader;
+
+ /**
+ * This is the classloader of this container. All classes and resources that
+ * the bean uses will be loaded from here. By doing this we make the bean
+ * re-deployable
+ */
+ protected ClassLoader classLoader;
+
+ /** The class loader for remote dynamic classloading */
+ protected ClassLoader webClassLoader;
+
+ /**
+ * Externally supplied configuration data
+ */
+ private DeploymentInfo di;
+
+ /**
+ * This is the new metadata. it includes information from both ejb-jar and
+ * jboss.xml the metadata for the application can be accessed trough
+ * metaData.getApplicationMetaData()
+ */
+ protected BeanMetaData metaData;
+
+ /** This is the EnterpriseBean class */
+ protected Class beanClass;
+
+ /** This is the Home interface class */
+ protected Class homeInterface;
+
+ /** This is the Remote interface class */
+ protected Class remoteInterface;
+
+ /** The local home interface class */
+ protected Class localHomeInterface;
+
+ /** The local inteface class */
+ protected Class localInterface;
+
+ /** This is the TransactionManager */
+ protected TransactionManager tm;
+
+ /** This is the SecurityManager */
+ protected AuthenticationManager sm;
+
+ /** This is the realm mapping */
+ protected RealmMapping rm;
+
+ /** The custom security proxy used by the SecurityInterceptor */
+ protected Object securityProxy;
+
+ /** This is the bean lock manager that is to be used */
+ protected BeanLockManager lockManager;
+
+ /** ??? */
+ protected LocalProxyFactory localProxyFactory =
+ new BaseLocalProxyFactory();
+
+ /** This is a cache for method permissions */
+ private HashMap methodPermissionsCache = new HashMap();
+
+ /** Maps for MarshalledInvocation mapping */
+ protected Map marshalledInvocationMapping = new HashMap();
+
+ /** ObjectName of Container */
+ private ObjectName jmxName;
+ /** HashMap<String, EJBProxyFactory> for the invoker bindings */
+ protected HashMap proxyFactories = new HashMap();
+ /** A priviledged actions for MBeanServer.invoke when running with sec mgr */
+ private MBeanServerAction serverAction = new MBeanServerAction();
+
+ /**
+ * The Proxy factory is set in the Invocation. This TL is used
+ * for methods that do not have access to the Invocation.
+ */
+ protected ThreadLocal proxyFactoryTL = new ThreadLocal();
+
+ /** The number of create invocations that have been made */
+ protected long createCount;
+ /** The number of create invocations that have been made */
+ protected long removeCount;
+ /** Time statistics for the invoke(Invocation) methods */
+ protected InvocationStatistics invokeStats = new InvocationStatistics();
+
+ /** The JACC context id for the container */
+ protected String jaccContextID;
+
+ /**
+ * Flag to denote whether a JACC configuration has been fitted for authorization
+ */
+ protected boolean isJaccEnabled = false;
+
+ static
+ {
+ try
+ {
+ EJBOBJECT_REMOVE = EJBObject.class.getMethod("remove", new Class[0]);
+ EJB_TIMEOUT = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
+ }
+ catch (Throwable t)
+ {
+ throw new NestedRuntimeException(t);
+ }
+ }
+
+ // Public --------------------------------------------------------
+
+ public Class getLocalClass()
+ {
+ return localInterface;
+ }
+
+ public Class getLocalHomeClass()
+ {
+ return localHomeInterface;
+ }
+
+ public Class getRemoteClass()
+ {
+ return remoteInterface;
+ }
+
+ /**
+ * this actually should be called remotehome, but for interface compliance purposes
+ * we keep it like that
+ */
+ public Class getHomeClass()
+ {
+ return homeInterface;
+ }
+
+ /**
+ * Whether the bean is call by value
+ *
+ * @return true for call by value
+ */
+ public boolean isCallByValue()
+ {
+ if (ejbModule.isCallByValue())
+ return true;
+ return metaData.isCallByValue();
+ }
+
+ /**
+ * Sets a transaction manager for this container.
+ *
+ * @see javax.transaction.TransactionManager
+ *
+ * @param tm
+ */
+ public void setTransactionManager(final TransactionManager tm)
+ {
+ this.tm = tm;
+ }
+
+ /**
+ * Returns this container's transaction manager.
+ *
+ * @return A concrete instance of javax.transaction.TransactionManager
+ */
+ public TransactionManager getTransactionManager()
+ {
+ return tm;
+ }
+
+ public void setSecurityManager(AuthenticationManager sm)
+ {
+ this.sm = sm;
+ }
+
+ public AuthenticationManager getSecurityManager()
+ {
+ return sm;
+ }
+
+ public BeanLockManager getLockManager()
+ {
+ return lockManager;
+ }
+
+ public void setLockManager(final BeanLockManager lockManager)
+ {
+ this.lockManager = lockManager;
+ lockManager.setContainer(this);
+ }
+
+ public void addProxyFactory(String invokerBinding, EJBProxyFactory factory)
+ {
+ proxyFactories.put(invokerBinding, factory);
+ }
+
+ public void setRealmMapping(final RealmMapping rm)
+ {
+ this.rm = rm;
+ }
+
+ public RealmMapping getRealmMapping()
+ {
+ return rm;
+ }
+
+ public void setSecurityProxy(Object proxy)
+ {
+ this.securityProxy = proxy;
+ }
+
+ public Object getSecurityProxy()
+ {
+ return securityProxy;
+ }
+
+ public EJBProxyFactory getProxyFactory()
+ {
+ EJBProxyFactory factory = (EJBProxyFactory)proxyFactoryTL.get();
+ // There's no factory thread local which means this is probably
+ // a local invocation. Just use the first (usually only)
+ // proxy factory.
+ // TODO: define a default factory in the meta data or
+ // even better, let the return over the original transport
+ // plugin the transport layer for the generated proxy
+ if (factory == null && remoteInterface != null)
+ {
+ Iterator i = proxyFactories.values().iterator();
+ if (i.hasNext())
+ factory = (EJBProxyFactory)i.next();
+ }
+ return factory;
+ }
+
+ public void setProxyFactory(Object factory)
+ {
+ proxyFactoryTL.set(factory);
+ }
+
+ public EJBProxyFactory lookupProxyFactory(String binding)
+ {
+ return (EJBProxyFactory)proxyFactories.get(binding);
+ }
+
+ /**
+ * Gets the DeploymentInfo for this Container
+ *
+ * @return The DeploymentInfo for this Container
+ */
+ public final DeploymentInfo getDeploymentInfo()
+ {
+ return di;
+ }
+
+ /**
+ * Sets the DeploymentInfo of this Container
+ *
+ * @param di The new DeploymentInfo to be used
+ */
+ public final void setDeploymentInfo(DeploymentInfo di)
+ {
+ this.di = di;
+ }
+
+ /**
+ * Sets the application deployment unit for this container. All the bean
+ * containers within the same application unit share the same instance.
+ *
+ * @param app application for this container
+ */
+ public void setEjbModule(EjbModule app)
+ {
+ ejbModule = app;
+ }
+
+ public String getJaccContextID()
+ {
+ return jaccContextID;
+ }
+
+ public void setJaccContextID(String id)
+ {
+ jaccContextID = id;
+ }
+
+ /**
+ * Get the flag whether JACC is enabled
+ * @return
+ */
+ public boolean isJaccEnabled()
+ {
+ return isJaccEnabled;
+ }
+
+ /**
+ * Set the flag that JACC is enabled
+ *
+ * @param isJaccEnabled
+ */
+ public void setJaccEnabled(boolean isJaccEnabled)
+ {
+ this.isJaccEnabled = isJaccEnabled;
+ }
+
+ /**
+ * Gets the application deployment unit for this container. All the bean
+ * containers within the same application unit share the same instance.
+ * @jmx.managed-attribute
+ */
+ public EjbModule getEjbModule()
+ {
+ return ejbModule;
+ }
+
+ /**
+ * Gets the number of create invocations that have been made
+ * @jmx.managed-attribute
+ */
+ public long getCreateCount()
+ {
+ return createCount;
+ }
+
+ /**
+ * Gets the number of remove invocations that have been made
+ * @jmx.managed-attribute
+ */
+ public long getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ /** Gets the invocation statistics collection
+ * @jmx.managed-attribute
+ */
+ public InvocationStatistics getInvokeStats()
+ {
+ return invokeStats;
+ }
+
+ /**
+ * Sets the local class loader for this container.
+ * Used for loading resources from the local jar file for this container.
+ * NOT for loading classes!
+ *
+ * @param cl
+ */
+ public void setLocalClassLoader(ClassLoader cl)
+ {
+ this.localClassLoader = cl;
+ }
+
+ /**
+ * Returns the local classloader for this container.
+ *
+ * @return The local classloader for this container.
+ */
+ public ClassLoader getLocalClassLoader()
+ {
+ return localClassLoader;
+ }
+
+ /**
+ * Sets the class loader for this container. All the classes and resources
+ * used by the bean in this container will use this classloader.
+ *
+ * @param cl
+ */
+ public void setClassLoader(ClassLoader cl)
+ {
+ this.classLoader = cl;
+ }
+
+ /**
+ * Returns the classloader for this container.
+ *
+ * @return
+ */
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /** Get the class loader for dynamic class loading via http.
+ */
+ public ClassLoader getWebClassLoader()
+ {
+ return webClassLoader;
+ }
+
+ /** Set the class loader for dynamic class loading via http.
+ */
+ public void setWebClassLoader(final ClassLoader webClassLoader)
+ {
+ this.webClassLoader = webClassLoader;
+ }
+
+ /**
+ * Sets the meta data for this container. The meta data consists of the
+ * properties found in the XML descriptors.
+ *
+ * @param metaData
+ */
+ public void setBeanMetaData(final BeanMetaData metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ /** Get the components environment context
+ * @jmx.managed-attribute
+ * @return Environment Context
+ */
+ public Context getEnvContext() throws NamingException
+ {
+ ClassLoader ccl = SecurityActions.getContextClassLoader();
+ try
+ {
+ // The ENC is a map keyed on the class loader
+ SecurityActions.setContextClassLoader(classLoader);
+ return (Context)new InitialContext().lookup("java:comp/env");
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(ccl);
+ }
+ }
+
+ /**
+ * Returns the metadata of this container.
+ *
+ * @jmx.managed-attribute
+ * @return metaData;
+ */
+ public BeanMetaData getBeanMetaData()
+ {
+ return metaData;
+ }
+
+ /**
+ * Returns the permissions for a method. (a set of roles)
+ *
+ * @return assemblyDescriptor;
+ */
+ public Set getMethodPermissions(Method m, InvocationType iface)
+ {
+ Set permissions;
+
+ if (methodPermissionsCache.containsKey(m))
+ {
+ permissions = (Set) methodPermissionsCache.get(m);
+ }
+ else if( m.equals(EJB_TIMEOUT) )
+ {
+ // No role is required to access the ejbTimeout as this is
+ permissions = new HashSet();
+ permissions.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ methodPermissionsCache.put(m, permissions);
+ }
+ else
+ {
+ String name = m.getName();
+ Class[] sig = m.getParameterTypes();
+ permissions = getBeanMetaData().getMethodPermissions(name, sig, iface);
+ methodPermissionsCache.put(m, permissions);
+ }
+
+ return permissions;
+ }
+
+ /**
+ * Returns the bean class instance of this container.
+ *
+ * @return instance of the Enterprise bean class.
+ */
+ public Class getBeanClass()
+ {
+ return beanClass;
+ }
+
+ /**
+ * Returns a new instance of the bean class or a subclass of the bean class.
+ * This factory style method is speciffically used by a container to supply
+ * an implementation of the abstract accessors in EJB2.0, but could be
+ * usefull in other situations. This method should ALWAYS be used instead
+ * of getBeanClass().newInstance();
+ *
+ * @return the new instance
+ *
+ * @see java.lang.Class#newInstance
+ */
+ public Object createBeanClassInstance() throws Exception
+ {
+ return getBeanClass().newInstance();
+ }
+
+ /**
+ * Sets the codebase of this container.
+ *
+ * @param codebase a possibly empty, but non null String with
+ * a sequence of URLs separated by spaces
+ * /
+ public void setCodebase(final String codebase)
+ {
+ if (codebase != null)
+ this.codebase = codebase;
+ }
+ */
+ /**
+ * Gets the codebase of this container.
+ *
+ * @return this container's codebase String, a sequence of URLs
+ * separated by spaces
+ * /
+ public String getCodebase()
+ {
+ return codebase;
+ }
+ */
+ /** Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName]
+ where the [jndiName] is either the bean remote home JNDI binding, or
+ the local home JNDI binding if the bean has no remote interfaces.
+ */
+ public ObjectName getJmxName()
+ {
+ if (jmxName == null)
+ {
+ BeanMetaData beanMetaData = getBeanMetaData();
+ if (beanMetaData == null)
+ {
+ throw new IllegalStateException("Container metaData is null");
+ }
+
+ String jndiName = beanMetaData.getContainerObjectNameJndiName();
+ if (jndiName == null)
+ {
+ throw new IllegalStateException("Container jndiName is null");
+ }
+
+ // The name must be escaped since the jndiName may be arbitrary
+ String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName;
+ try
+ {
+ jmxName = ObjectNameConverter.convert(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage());
+ }
+ }
+ return jmxName;
+ }
+
+ /**
+ * Creates the single Timer Service for this container if not already created
+ *
+ * @param pKey Bean id
+ * @return Container Timer Service
+ * @throws IllegalStateException If the type of EJB is not allowed to use the
+ * timer service, or the bean class does not implement javax.ejb.TimedObject
+ *
+ * @see javax.ejb.EJBContext#getTimerService
+ *
+ * @jmx.managed-operation
+ **/
+ public TimerService getTimerService(Object pKey)
+ throws IllegalStateException
+ {
+ if (this instanceof StatefulSessionContainer)
+ throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService");
+
+ // Validate that the bean implements the TimedObject interface
+ Class beanClass = this.getBeanClass();
+ if( TimedObject.class.isAssignableFrom(beanClass) == false )
+ {
+ String msg = this.getBeanMetaData().getEjbName()
+ +" requested getTimerService but "+beanClass
+ +" does not implement javax.ejb.TimedObject";
+ throw new IllegalStateException(msg);
+ }
+
+ TimerService timerService = null;
+ try
+ {
+ EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
+ timerService = service.createTimerService(getJmxName(), pKey, this);
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Could not create timer service", e);
+ }
+ return timerService;
+ }
+
+ /**
+ * Removes Timer Service for this container
+ *
+ * @param pKey Bean id
+ * @throws IllegalStateException If the type of EJB is not allowed to use the timer service
+ *
+ * @jmx.managed-operation
+ **/
+ public void removeTimerService(Object pKey)
+ throws IllegalStateException
+ {
+ try
+ {
+ EJBTimerService service = (EJBTimerService)SecurityActions.getMBeanProxy(EJBTimerService.class, EJBTimerService.OBJECT_NAME, server);
+ if (pKey != null)
+ {
+ // entity bean->remove()
+ service.removeTimerService(getJmxName(), pKey);
+ }
+ else
+ {
+ // container stop, we choose whether active timers
+ // should be persisted (default), or not (legacy)
+ service.removeTimerService(getJmxName(), getBeanMetaData().getTimerPersistence());
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Could not remove timer service", e);
+ }
+ }
+
+ /**
+ * Restore any timers previously persisted for this container
+ */
+ protected void restoreTimers()
+ {
+ try
+ {
+ // pass to the ejb timer service the container ObjectName
+ server.invoke(
+ EJBTimerService.OBJECT_NAME,
+ "restoreTimers",
+ new Object[] { getServiceName(), getClassLoader() },
+ new String[] { "javax.management.ObjectName" , "java.lang.ClassLoader" } );
+ }
+ catch (Exception e)
+ {
+ log.warn("Could not restore ejb timers", e);
+ }
+ }
+
+ /**
+ * The EJBDeployer calls this method. The EJBDeployer has set
+ * all the plugins and interceptors that this bean requires and now proceeds
+ * to initialize the chain. The method looks for the standard classes in
+ * the URL, sets up the naming environment of the bean. The concrete
+ * container classes should override this method to introduce
+ * implementation specific initialization behaviour.
+ *
+ * @throws Exception if loading the bean class failed
+ * (ClassNotFoundException) or setting up "java:"
+ * naming environment failed (DeploymentException)
+ */
+ protected void createService() throws Exception
+ {
+ // Acquire classes from CL
+ beanClass = classLoader.loadClass(metaData.getEjbClass());
+
+ if (metaData.getLocalHome() != null)
+ localHomeInterface = classLoader.loadClass(metaData.getLocalHome());
+ if (metaData.getLocal() != null)
+ localInterface = classLoader.loadClass(metaData.getLocal());
+
+ localProxyFactory.setContainer(this);
+ localProxyFactory.create();
+ if (localHomeInterface != null)
+ ejbModule.addLocalHome(this, localProxyFactory.getEJBLocalHome());
+ ejbModule.createMissingPermissions(this, metaData);
+ // Allow the policy to incorporate the policy configs
+ Policy.getPolicy().refresh();
+ }
+
+ /**
+ * A default implementation of starting the container service.
+ * The container registers it's dynamic MBean interface in the JMX base.
+ *
+ * The concrete container classes should override this method to introduce
+ * implementation specific start behaviour.
+ *
+ * todo implement the service lifecycle methods in an xmbean interceptor so
+ * non lifecycle managed ops are blocked when mbean is not started.
+ *
+ * @throws Exception An exception that occured during start
+ */
+ protected void startService() throws Exception
+ {
+ // Setup "java:comp/env" namespace
+ setupEnvironment();
+
+ localProxyFactory.start();
+ }
+
+ /**
+ * A default implementation of stopping the container service (no-op). The
+ * concrete container classes should override this method to introduce
+ * implementation specific stop behaviour.
+ */
+ protected void stopService() throws Exception
+ {
+ localProxyFactory.stop();
+ removeTimerService(null);
+ teardownEnvironment();
+ }
+
+ /**
+ * A default implementation of destroying the container service (no-op).
+ * The concrete container classes should override this method to introduce
+ * implementation specific destroy behaviour.
+ */
+ protected void destroyService() throws Exception
+ {
+ localProxyFactory.destroy();
+ ejbModule.removeLocalHome(this);
+
+ beanClass = null;
+ homeInterface = null;
+ remoteInterface = null;
+ localHomeInterface = null;
+ localInterface = null;
+ methodPermissionsCache.clear();
+ // InvocationStatistics holds refs to Methods from
+ // application classes, so to avoid a classloader
+ // leak, lets not just resetStats() but also replace
+ // the object
+ invokeStats.resetStats(); // in case someone else has a ref
+ invokeStats = new InvocationStatistics();
+ marshalledInvocationMapping.clear();
+ }
+
+ /**
+ * This method is called when a method call comes
+ * in on the Home object. The Container forwards this call to the
+ * interceptor chain for further processing.
+ *
+ * @param mi the object holding all info about this invocation
+ * @return the result of the home invocation
+ *
+ * @throws Exception
+ */
+ public abstract Object internalInvokeHome(Invocation mi)
+ throws Exception;
+
+ /**
+ * This method is called when a method call comes
+ * in on an EJBObject. The Container forwards this call to the interceptor
+ * chain for further processing.
+ */
+ public abstract Object internalInvoke(Invocation mi)
+ throws Exception;
+
+ abstract Interceptor createContainerInterceptor();
+
+ public abstract void addInterceptor(Interceptor in);
+
+ /** The detached invoker operation.
+ *
+ * @jmx.managed-operation
+ *
+ * @param mi - the method invocation context
+ * @return the value of the ejb invocation
+ * @throws Exception on error
+ */
+ public Object invoke(Invocation mi)
+ throws Exception
+ {
+ ClassLoader callerClassLoader = SecurityActions.getContextClassLoader();
+ long start = System.currentTimeMillis();
+ Method m = null;
+
+ Object type = null;
+ String contextID = getJaccContextID();
+ try
+ {
+ // JBAS-3732 - Remove classloader.equals optimization
+ SecurityActions.setContextClassLoader(this.classLoader);
+
+ // Set the JACC context id
+ mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID);
+ contextID = SecurityActions.setContextID(contextID);
+ // Set the standard JACC policy context handler data is not a SEI msg
+ if (mi.getType() != InvocationType.SERVICE_ENDPOINT)
+ {
+ EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
+ }
+ else
+ {
+ SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE);
+ SOAPMsgPolicyContextHandler.setMessage(msg);
+ }
+ // Set custom JACC policy handlers
+ BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData());
+
+ // Check against home, remote, localHome, local, getHome,
+ // getRemote, getLocalHome, getLocal
+ type = mi.getType();
+
+ // stat gathering: concurrent calls
+ this.invokeStats.callIn();
+
+ if (type == InvocationType.REMOTE ||
+ type == InvocationType.LOCAL ||
+ // web service calls come in as "ordinary" application invocations
+ type == InvocationType.SERVICE_ENDPOINT)
+ {
+ if (mi instanceof MarshalledInvocation)
+ {
+ ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("METHOD REMOTE INVOKE " +
+ mi.getObjectName() + "||" +
+ mi.getMethod().getName() + "||");
+ }
+ }
+
+ m = mi.getMethod();
+
+ Object obj = internalInvoke(mi);
+ return obj;
+ }
+ else if (type == InvocationType.HOME ||
+ type == InvocationType.LOCALHOME)
+ {
+ if (mi instanceof MarshalledInvocation)
+ {
+
+ ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("METHOD HOME INVOKE " +
+ mi.getObjectName() + "||" +
+ mi.getMethod().getName() + "||" +
+ mi.getArguments().toString());
+ }
+ }
+ m = mi.getMethod();
+
+ Object obj = internalInvokeHome(mi);
+ return obj;
+ }
+ else
+ {
+ throw new MBeanException(new IllegalArgumentException(
+ "Unknown invocation type: " + type));
+ }
+ }
+ /**
+ * Having to catch this exception here in case can not
+ * unmarshall arguments, values, etc. Then, convert to
+ * UnmarshalException as defined by spec (JBAS-2999)
+ */
+ catch (JBossLazyUnmarshallingException e)
+ {
+ InvocationType calltype = mi.getType();
+ boolean isLocal =
+ calltype == InvocationType.LOCAL ||
+ calltype == InvocationType.LOCALHOME;
+
+ // handle unmarshalling exception which should only come if problem unmarshalling
+ // invocation payload, arguments, or value on remote end.
+ if (isLocal)
+ {
+ throw new EJBException("UnmarshalException", e);
+ }
+ else
+ {
+ throw new MarshalException("MarshalException", e);
+ }
+ }
+ finally
+ {
+ if (m != null)
+ {
+ long end = System.currentTimeMillis();
+ long elapsed = end - start;
+ this.invokeStats.updateStats(m, elapsed);
+ }
+
+ // stat gathering: concurrent calls
+ this.invokeStats.callOut();
+
+ // Restore the incoming class loader
+ SecurityActions.setContextClassLoader(callerClassLoader);
+
+ // Restore the incoming context id
+ contextID = SecurityActions.setContextID(contextID);
+
+ if (mi.getType() == InvocationType.SERVICE_ENDPOINT)
+ {
+ // Remove msg from ThreadLocal to prevent leakage into the thread pool
+ SOAPMsgPolicyContextHandler.setMessage(null);
+ }
+ else
+ {
+ // Remove args from ThreadLocal to prevent leakage into the thread pool
+ EJBArgsPolicyContextHandler.setArgs(null);
+ }
+
+ // Remove metadata from ThreadLocal to prevent leakage into the thread pool
+ BeanMetaDataPolicyContextHandler.setMetaData(null);
+ }
+ }
+
+ // Private -------------------------------------------------------
+
+ /**
+ * This method sets up the naming environment of the bean.
+ * We create the java:comp/env namespace with properties, EJB-References,
+ * and DataSource ressources.
+ */
+ private void setupEnvironment() throws Exception
+ {
+ BeanMetaData beanMetaData = getBeanMetaData();
+ // debug
+ log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName());
+ ClassLoader tcl = SecurityActions.getContextClassLoader();
+ log.debug("TCL: " + tcl);
+
+ ORB orb = null;
+ HandleDelegate hd = null;
+ try
+ {
+ orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
+ hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate");
+ }
+ catch (Throwable t)
+ {
+ log.debug("Unable to retrieve orb" + t.toString());
+ }
+
+ // Since the BCL is already associated with this thread we can start
+ // using the java: namespace directly
+ Context ctx = (Context)new InitialContext().lookup("java:comp");
+
+ // Bind the orb
+ if (orb != null)
+ {
+ NonSerializableFactory.rebind(ctx, "ORB", orb);
+ log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
+
+ NonSerializableFactory.rebind(ctx, "HandleDelegate", hd);
+ log.debug("Bound java:comp:/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
+ }
+
+ Context envCtx = ctx.createSubcontext("env");
+
+ // Bind environment properties
+ {
+ Iterator i = beanMetaData.getEnvironmentEntries();
+ while (i.hasNext())
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData)i.next();
+
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+ entry.getType() + " to value:" + entry.getValue());
+
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+ }
+
+ // Bind EJB references
+ {
+ Iterator i = beanMetaData.getEjbReferences();
+ while (i.hasNext())
+ {
+ EjbRefMetaData ref = (EjbRefMetaData)i.next();
+ log.debug("Binding an EJBReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ String linkName = ref.getLink();
+ String jndiName = EjbUtil.findEjbLink(server, di, linkName);
+
+ log.debug("Binding " + ref.getName() +
+ " to ejb-link: " + linkName + " -> " + jndiName);
+
+ if (jndiName == null)
+ {
+ String msg = "Failed to resolve ejb-link: " + linkName
+ + " make by ejb-name: " + ref.getName();
+ throw new DeploymentException(msg);
+ }
+
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(jndiName));
+
+ }
+ else
+ {
+ // Get the invoker specific ejb-ref mappings
+ Iterator it = beanMetaData.getInvokerBindings();
+ Reference reference = null;
+ while (it.hasNext())
+ {
+ String invokerBinding = (String)it.next();
+ // Check for an invoker level jndi-name
+ String name = ref.getInvokerBinding(invokerBinding);
+ // Check for an global jndi-name
+ if (name == null)
+ name = ref.getJndiName();
+ if (name == null)
+ {
+ throw new DeploymentException
+ ("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml or " +
+ "jndi-name in jboss.xml");
+ }
+
+ StringRefAddr addr = new StringRefAddr(invokerBinding, name);
+ log.debug("adding " + invokerBinding + ":" + name +
+ " to Reference");
+
+ if (reference == null)
+ {
+ reference = new Reference("javax.naming.LinkRef",
+ ENCThreadLocalKey.class.getName(),
+ null);
+ }
+ reference.add(addr);
+ }
+
+ // If there were invoker bindings create bind the reference
+ if (reference != null)
+ {
+ if (ref.getJndiName() != null)
+ {
+ // Add default for the bean level ejb-ref/jndi-name
+ StringRefAddr addr =
+ new StringRefAddr("default", ref.getJndiName());
+ reference.add(addr);
+ }
+ if (reference.size() == 1 && reference.get("default") == null)
+ {
+ /* There is only one invoker binding and its not default so
+ create a default binding to allow the link to have a value
+ when accessed without an invoker active.
+ */
+ StringRefAddr addr = (StringRefAddr)reference.get(0);
+ String target = (String)addr.getContent();
+ StringRefAddr addr1 = new StringRefAddr("default", target);
+ reference.add(addr1);
+ }
+ Util.bind(envCtx, ref.getName(), reference);
+ }
+ else
+ {
+ // Bind the bean level ejb-ref/jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or jndi-name in jboss.xml");
+ }
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(ref.getJndiName()));
+ }
+ }
+ }
+ }
+
+ // Bind Local EJB references
+ {
+ Iterator i = beanMetaData.getEjbLocalReferences();
+ while (i.hasNext())
+ {
+ EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
+ String refName = ref.getName();
+ log.debug("Binding an EJBLocalReference " + ref.getName());
+
+ if (ref.getLink() != null)
+ {
+ // Internal link
+ log.debug("Binding " + refName + " to bean source: " + ref.getLink());
+
+ String jndiName = EjbUtil.findLocalEjbLink(server, di,
+ ref.getLink());
+
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(jndiName));
+ }
+ else
+ {
+ // Bind the bean level ejb-local-ref/local-jndi-name
+ if (ref.getJndiName() == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ref.getName() +
+ ", expected either ejb-link in ejb-jar.xml " +
+ "or local-jndi-name in jboss.xml");
+ }
+ Util.bind(envCtx,
+ ref.getName(),
+ new LinkRef(ref.getJndiName()));
+ }
+ }
+ }
+
+ // Bind service references
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+
+ // Bind resource references
+ {
+ Iterator i = beanMetaData.getResourceReferences();
+
+ // let's play guess the cast game ;) New metadata should fix this.
+ ApplicationMetaData application =
+ beanMetaData.getApplicationMetaData();
+
+ while (i.hasNext())
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData)i.next();
+
+ String resourceName = ref.getResourceName();
+ String finalName = application.getResourceByName(resourceName);
+ String resType = ref.getType();
+ // If there was no resource-manager specified then an immeadiate
+ // jndi-name or res-url name should have been given
+ if (finalName == null)
+ finalName = ref.getJndiName();
+
+ if (finalName == null && resType.equals("java.net.URL") == false)
+ {
+ // the application assembler did not provide a resource manager
+ // if the type is javax.sql.Datasoure use the default one
+
+ if (ref.getType().equals("javax.sql.DataSource"))
+ {
+ // Go through JNDI and look for DataSource - use the first one
+ Context dsCtx = new InitialContext();
+ try
+ {
+ // Check if it is available in JNDI
+ dsCtx.lookup("java:/DefaultDS");
+ finalName = "java:/DefaultDS";
+ }
+ catch (Exception e)
+ {
+ log.debug("failed to lookup DefaultDS; ignoring", e);
+ }
+ finally
+ {
+ dsCtx.close();
+ }
+ }
+
+ // Default failed? Warn user and move on
+ // POTENTIALLY DANGEROUS: should this be a critical error?
+ if (finalName == null)
+ {
+ log.warn("No resource manager found for " +
+ ref.getResourceName());
+ continue;
+ }
+ }
+
+ if (resType.equals("java.net.URL"))
+ {
+ // URL bindings
+ if (ref.getResURL() != null)
+ {
+ // The URL string was given by the res-url
+ log.debug("Binding URL: " + ref.getRefName() +
+ " to JDNI ENC as: " + ref.getResURL());
+ URL resURL = new URL(ref.getResURL());
+ Util.bind(envCtx, ref.getRefName(), resURL);
+ }
+ else
+ {
+ log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
+ Object bind = null;
+ if (ref.getJndiName() != null)
+ {
+ // Was the url given as a jndi-name reference to link to it
+ bind = new LinkRef(finalName);
+ }
+ else
+ {
+ // The url string was given via a resource-name mapping
+ bind = new URL(finalName);
+ }
+ Util.bind(envCtx, ref.getRefName(), bind);
+ }
+ }
+ else
+ {
+ // Resource Manager bindings, should validate the type...
+ log.debug("Binding resource manager: " + ref.getRefName() +
+ " to JDNI ENC as: " + finalName);
+
+ Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
+ }
+ }
+ }
+
+ // Bind resource env references
+ {
+ Iterator i = beanMetaData.getResourceEnvReferences();
+ while (i.hasNext())
+ {
+ ResourceEnvRefMetaData resRef =
+ (ResourceEnvRefMetaData)i.next();
+ String encName = resRef.getRefName();
+ String jndiName = resRef.getJndiName();
+ // Should validate the type...
+ log.debug("Binding env resource: " + encName +
+ " to JDNI ENC as: " + jndiName);
+
+ Util.bind(envCtx, encName, new LinkRef(jndiName));
+ }
+ }
+
+ // Bind message destination references
+ {
+ Iterator i = beanMetaData.getMessageDestinationReferences();
+
+ while (i.hasNext())
+ {
+ MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();
+
+ String refName = ref.getRefName();
+ String jndiName = ref.getJNDIName();
+ String link = ref.getLink();
+ if (link != null)
+ {
+ if (jndiName == null)
+ {
+ MessageDestinationMetaData messageDestination = getMessageDestination(link);
+ if (messageDestination == null)
+ throw new DeploymentException("message-destination-ref '" + refName +
+ "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml");
+ else
+ {
+ String linkJNDIName = messageDestination.getJNDIName();
+ if (linkJNDIName == null)
+ log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml");
+ else
+ jndiName = linkJNDIName;
+ }
+ }
+ else
+ log.warn("message-destination-ref '" + refName +
+ "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml");
+ }
+ else if (jndiName == null)
+ throw new DeploymentException("message-destination-ref '" + refName +
+ "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml");
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
+
+ // Create a java:comp/env/security/security-domain link to the container
+ // or application security-domain if one exists so that access to the
+ // security manager can be made without knowing the global jndi name.
+
+ String securityDomain =
+ metaData.getContainerConfiguration().getSecurityDomain();
+ if (securityDomain == null)
+ securityDomain = metaData.getApplicationMetaData().getSecurityDomain();
+ if (securityDomain != null)
+ {
+ log.debug("Binding securityDomain: " + securityDomain +
+ " to JDNI ENC as: security/security-domain");
+
+ Util.bind(envCtx,
+ "security/security-domain",
+ new LinkRef(securityDomain));
+ Util.bind(envCtx,
+ "security/subject",
+ new LinkRef(securityDomain + "/subject"));
+ }
+
+ log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName());
+ }
+
+ public MessageDestinationMetaData getMessageDestination(String link)
+ {
+ return EjbUtil.findMessageDestination(server, di, link);
+ }
+
+ /**
+ *The <code>teardownEnvironment</code> method unbinds everything from
+ * the comp/env context. It would be better do destroy the env context
+ * but destroyContext is not currently implemented..
+ *
+ * @exception Exception if an error occurs
+ */
+ private void teardownEnvironment() throws Exception
+ {
+ Context ctx = (Context)new InitialContext().lookup("java:comp");
+ ctx.unbind("env");
+ log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName());
+ try
+ {
+ NonSerializableFactory.unbind("ORB");
+ log.debug("Unbound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName());
+
+ NonSerializableFactory.unbind("HandleDelegate");
+ log.debug("Unbound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
+ }
+ catch (NamingException ignored)
+ {
+ }
+ }
+
+ /**
+ * The base class for container interceptors.
+ *
+ * <p>
+ * All container interceptors perform the same basic functionality
+ * and only differ slightly.
+ */
+ protected abstract class AbstractContainerInterceptor
+ implements Interceptor
+ {
+ protected final Logger log = Logger.getLogger(this.getClass());
+
+ public void setContainer(Container con)
+ {
+ }
+
+ public void setNext(Interceptor interceptor)
+ {
+ }
+
+ public Interceptor getNext()
+ {
+ return null;
+ }
+
+ public void create()
+ {
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ protected void rethrow(Exception e)
+ throws Exception
+ {
+ if (e instanceof IllegalAccessException)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ }
+ else if (e instanceof InvocationTargetException)
+ {
+ Throwable t = ((InvocationTargetException)e).getTargetException();
+
+ if (t instanceof EJBException)
+ {
+ throw (EJBException)t;
+ }
+ else if (t instanceof Exception)
+ {
+ throw (Exception)t;
+ }
+ else if (t instanceof Error)
+ {
+ throw (Error)t;
+ }
+ else
+ {
+ throw new NestedError("Unexpected Throwable", t);
+ }
+ }
+
+ throw e;
+ }
+
+ // Monitorable implementation ------------------------------------
+
+ public void sample(Object s)
+ {
+ // Just here to because Monitorable request it but will be removed soon
+ }
+
+ public Map retrieveStatistic()
+ {
+ return null;
+ }
+
+ public void resetStatistic()
+ {
+ }
+ }
+
+ /** Perform the MBeanServer.invoke op in a PrivilegedExceptionAction if
+ * running with a security manager.
+ */
+ class MBeanServerAction implements PrivilegedExceptionAction
+ {
+ private ObjectName target;
+ String method;
+ Object[] args;
+ String[] sig;
+
+ MBeanServerAction()
+ {
+ }
+
+ MBeanServerAction(ObjectName target, String method, Object[] args, String[] sig)
+ {
+ this.target = target;
+ this.method = method;
+ this.args = args;
+ this.sig = sig;
+ }
+
+ public Object run() throws Exception
+ {
+ Object rtnValue = server.invoke(target, method, args, sig);
+ return rtnValue;
+ }
+
+ Object invoke(ObjectName target, String method, Object[] args, String[] sig)
+ throws Exception
+ {
+ SecurityManager sm = System.getSecurityManager();
+ Object rtnValue = null;
+ if (sm == null)
+ {
+ // Direct invocation on MBeanServer
+ rtnValue = server.invoke(target, method, args, sig);
+ }
+ else
+ {
+ try
+ {
+ // Encapsulate the invocation in a PrivilegedExceptionAction
+ MBeanServerAction action = new MBeanServerAction(target, method, args, sig);
+ rtnValue = AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ throw ex;
+ }
+ }
+ return rtnValue;
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/BeanMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/BeanMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/BeanMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1108 @@
+/*
+ * 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.metadata;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.invocation.InvocationType;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.NobodyPrincipal;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+
+/**
+ * A common meta data class for the entity, message-driven and session beans.
+ *
+ * @author <a href="mailto:sebastien.alborini at m4x.org">Sebastien Alborini</a>
+ * @author <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author <a href="mailto:docodan at mvcsoft.com">Daniel OConnor</a>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:criege at riege.com">Christian Riege</a>
+ * @author <a href="mailto:Thomas.Diesler at jboss.org">Thomas Diesler</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ *
+ * @version $Revision: 69712 $
+ */
+public abstract class BeanMetaData
+ extends MetaData
+{
+ // Constants -----------------------------------------------------
+
+ public static final char SESSION_TYPE = 'S';
+ public static final char ENTITY_TYPE = 'E';
+ public static final char MDB_TYPE = 'M';
+ public static final String LOCAL_INVOKER_PROXY_BINDING = "LOCAL";
+
+ // Attributes ----------------------------------------------------
+ /** The metadata from the toplevel ejb-jar.xml/jboss.xml elements */
+ private ApplicationMetaData application;
+
+ // from ejb-jar.xml
+ /** The ejb-name element specifies an enterprise bean's name. This name is
+ assigned by the ejb-jar file producer to name the enterprise bean in
+ the ejb-jar file's deployment descriptor. The name must be unique
+ among the names of the enterprise beans in the same ejb-jar file.
+ */
+ private String ejbName;
+ /** The home element contains the fully-qualified name of the enterprise
+ bean's home interface. */
+ private String homeClass;
+ /** The remote element contains the fully-qualified name of the enterprise
+ bean's remote interface. */
+ private String remoteClass;
+ /** The local-home element contains the fully-qualified name of the
+ enterprise bean's local home interface. */
+ private String localHomeClass;
+ /** The local element contains the fully-qualified name of the enterprise
+ bean's local interface */
+ private String localClass;
+ /** The service-endpoint element contains the fully-qualified
+ * name of the bean�s service endpoint interface (SEI) */
+ protected String serviceEndpointClass;
+ /** The ejb-class element contains the fully-qualified name of the
+ enterprise bean's class. */
+ private String ejbClass;
+ /** The type of bean: ENTITY_TYPE, SESSION_TYPE, MDB_TYPE */
+ protected char beanType;
+ /** Is this bean's transactions managed by the container? */
+ protected boolean containerManagedTx = true;
+
+ /** The The env-entry element(s) contains the declaration of an enterprise
+ bean's environment entry */
+ private ArrayList environmentEntries = new ArrayList();
+ /** The The ejb-ref element(s) for the declaration of a reference to an
+ enterprise bean's home */
+ private HashMap ejbReferences = new HashMap();
+ /** The ejb-local-ref element(s) info */
+ private HashMap ejbLocalReferences = new HashMap();
+ /** The HashMap<ServiceRefMetaData> service-ref element(s) info */
+ private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
+ /** The security-role-ref element(s) info */
+ private ArrayList securityRoleReferences = new ArrayList();
+ /** The security-idemtity element info */
+ private SecurityIdentityMetaData securityIdentity = null;
+ /** */
+ private SecurityIdentityMetaData ejbTimeoutIdentity = null;
+ /** The resource-ref element(s) info */
+ private HashMap resourceReferences = new HashMap();
+ /** The resource-env-ref element(s) info */
+ private HashMap resourceEnvReferences = new HashMap();
+ /** The message destination references */
+ private HashMap messageDestinationReferences = new HashMap();
+ /** The method attributes */
+ private ArrayList methodAttributes = new ArrayList();
+ private ConcurrentReaderHashMap cachedMethodAttributes = new ConcurrentReaderHashMap();
+ /** The assembly-descriptor/method-permission element(s) info */
+ private ArrayList permissionMethods = new ArrayList();
+ /** The assembly-descriptor/container-transaction element(s) info */
+ private ArrayList transactionMethods = new ArrayList();
+ /** A cache mapping methods to transaction attributes. */
+ private ConcurrentReaderHashMap methodTx = new ConcurrentReaderHashMap();
+ /** The assembly-descriptor/exclude-list method(s) */
+ private ArrayList excludedMethods = new ArrayList();
+ /** The invoker names to JNDI name mapping */
+ protected HashMap invokerBindings = null;
+ /** The cluster-config element info */
+ private ClusterConfigMetaData clusterConfig = null;
+
+ /** The JNDI name under with the home interface should be bound */
+ private String jndiName;
+
+ /** The JNDI name under with the local home interface should be bound */
+ private String localJndiName;
+ /** The container configuration name */
+ protected String configurationName;
+ /** The container configuration metadata */
+ private ConfigurationMetaData configuration;
+ /** The custom security proxy class */
+ private String securityProxy;
+
+ /** Is the bean marked as clustered */
+ protected boolean clustered = false;
+ /** Should the bean use by value call semeantics */
+ protected boolean callByValue = false;
+ /** Any object names for services the bean depends on */
+ private Collection depends = new LinkedList();
+
+ /** Describes the security configuration information for the IOR. Optional element. Since 4.0. */
+ private IorSecurityConfigMetaData iorSecurityConfig;
+ /** The jboss port-component binding for a ejb webservice */
+ protected EjbPortComponentMetaData portComponent;
+ /** Whether to throw an exception on a rollback if there is no exception */
+ private boolean exceptionRollback = false;
+ /** Whether timer persistence is enabled */
+ private boolean timerPersistence = true;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public BeanMetaData(ApplicationMetaData app, char beanType)
+ {
+ this.application = app;
+ this.beanType = beanType;
+ }
+
+ public boolean isSession()
+ {
+ return beanType == SESSION_TYPE;
+ }
+
+ public boolean isMessageDriven()
+ {
+ return beanType == MDB_TYPE;
+ }
+
+ public boolean isEntity()
+ {
+ return beanType == ENTITY_TYPE;
+ }
+
+ public String getHome()
+ {
+ return homeClass;
+ }
+
+ public String getRemote()
+ {
+ return remoteClass;
+ }
+
+ public String getLocalHome()
+ {
+ return localHomeClass;
+ }
+
+ public String getLocal()
+ {
+ return localClass;
+ }
+
+ public String getServiceEndpoint()
+ {
+ return serviceEndpointClass;
+ }
+
+ public EjbPortComponentMetaData getPortComponent()
+ {
+ return portComponent;
+ }
+
+ public String getEjbClass()
+ {
+ return ejbClass;
+ }
+
+ public String getEjbName()
+ {
+ return ejbName;
+ }
+
+ public boolean isContainerManagedTx()
+ {
+ return containerManagedTx;
+ }
+
+ public boolean isBeanManagedTx()
+ {
+ return !containerManagedTx;
+ }
+
+ public Iterator getEjbReferences()
+ {
+ return ejbReferences.values().iterator();
+ }
+
+ public Iterator getEjbLocalReferences()
+ {
+ return ejbLocalReferences.values().iterator();
+ }
+
+ protected abstract void defaultInvokerBindings();
+
+ public Iterator getInvokerBindings()
+ {
+ if (invokerBindings == null)
+ {
+ // See if there is a container default invoker name
+ String[] defaultNames = configuration.getInvokers();
+ if (defaultNames.length > 0)
+ {
+ invokerBindings = new HashMap();
+ for (int count = 0; count < defaultNames.length; count++)
+ {
+ invokerBindings.put(defaultNames[count], getJndiName());
+ }
+ }
+ else
+ {
+ // Use the hard-coded defaults
+ defaultInvokerBindings();
+ }
+ }
+
+ return invokerBindings.keySet().iterator();
+ }
+
+ public String getInvokerBinding(String invokerName)
+ {
+ if (invokerBindings == null)
+ {
+ defaultInvokerBindings();
+ }
+
+ return (String)invokerBindings.get(invokerName);
+ }
+
+ public EjbRefMetaData getEjbRefByName(String name)
+ {
+ return (EjbRefMetaData)ejbReferences.get(name);
+ }
+
+ public EjbLocalRefMetaData getEjbLocalRefByName(String name)
+ {
+ return (EjbLocalRefMetaData)ejbLocalReferences.get(name);
+ }
+
+ public Iterator getEnvironmentEntries()
+ {
+ return environmentEntries.iterator();
+ }
+
+ public Iterator getSecurityRoleReferences()
+ {
+ return securityRoleReferences.iterator();
+ }
+
+ public Iterator getResourceReferences()
+ {
+ return resourceReferences.values().iterator();
+ }
+
+ public Iterator getResourceEnvReferences()
+ {
+ return resourceEnvReferences.values().iterator();
+ }
+
+ public Iterator getMessageDestinationReferences()
+ {
+ return messageDestinationReferences.values().iterator();
+ }
+
+ /**
+ * @return HashMap<ServiceRefMetaData>
+ */
+ public HashMap<String, ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public String getJndiName()
+ {
+ // jndiName may be set in jboss.xml
+ if (jndiName == null)
+ {
+ jndiName = ejbName;
+ }
+ return jndiName;
+ }
+
+ /**
+ * Gets the JNDI name under with the local home interface should be bound.
+ * The default is local/<ejbName>
+ */
+ public String getLocalJndiName()
+ {
+ if (localJndiName == null)
+ {
+ // Generate a unique name based on ejbName + identityHashCode
+ localJndiName = "local/" + ejbName + '@' + System.identityHashCode(ejbName);
+ }
+ return localJndiName;
+ }
+
+ /**
+ * Gets the container jndi name used in the object name
+ */
+ public String getContainerObjectNameJndiName()
+ {
+ return getHome() != null ? getJndiName() : getLocalJndiName();
+ }
+
+ public String getConfigurationName()
+ {
+ if (configurationName == null)
+ {
+ configurationName = getDefaultConfigurationName();
+ }
+ return configurationName;
+ }
+
+ public ConfigurationMetaData getContainerConfiguration()
+ {
+ if (configuration == null)
+ {
+ String configName = getConfigurationName();
+ configuration = application.getConfigurationMetaDataByName(configName);
+ if (configuration == null)
+ throw new IllegalStateException("Container config not found " + configName);
+ }
+ return configuration;
+ }
+
+ public String getSecurityProxy()
+ {
+ return securityProxy;
+ }
+
+ public SecurityIdentityMetaData getSecurityIdentityMetaData()
+ {
+ return securityIdentity;
+ }
+ public SecurityIdentityMetaData getEjbTimeoutIdentity()
+ {
+ return ejbTimeoutIdentity;
+ }
+
+ public ApplicationMetaData getApplicationMetaData()
+ {
+ return application;
+ }
+
+ public abstract String getDefaultConfigurationName();
+
+ public Iterator getTransactionMethods()
+ {
+ return transactionMethods.iterator();
+ }
+
+ public Iterator getPermissionMethods()
+ {
+ return permissionMethods.iterator();
+ }
+
+ public Iterator getExcludedMethods()
+ {
+ return excludedMethods.iterator();
+ }
+
+ public void addTransactionMethod(MethodMetaData method)
+ {
+ transactionMethods.add(method);
+ }
+
+ public void addPermissionMethod(MethodMetaData method)
+ {
+ // Insert unchecked methods into the front of the list to speed
+ // up their validation
+ if (method.isUnchecked())
+ {
+ permissionMethods.add(0, method);
+ }
+ else
+ {
+ permissionMethods.add(method);
+ }
+ }
+
+ public void addExcludedMethod(MethodMetaData method)
+ {
+ excludedMethods.add(method);
+ }
+
+ public byte getMethodTransactionType(String methodName, Class[] params, InvocationType iface)
+ {
+ // default value
+ byte result = TX_UNKNOWN;
+
+ MethodMetaData bestMatch = null;
+ Iterator iterator = getTransactionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+
+ // this is the first match
+ if (bestMatch == null)
+ {
+ bestMatch = m;
+ }
+ else
+ {
+ // this is a better match because the name is more precise
+ if (bestMatch.getMethodName().equals("*"))
+ {
+ bestMatch = m;
+ }
+ // this is a better match because now we have parameters, we cant get any better
+ if (m.getMethodParams().length > 0)
+ {
+ bestMatch = m;
+ break;
+ }
+ }
+ }
+ }
+
+ if (bestMatch != null)
+ {
+ result = bestMatch.getTransactionType();
+ }
+
+ return result;
+ }
+
+ // This should be cached, since this method is called very often
+ public byte getTransactionMethod(Method m, InvocationType iface)
+ {
+ if (m == null)
+ return MetaData.TX_SUPPORTS;
+
+ Byte b = (Byte)methodTx.get(m);
+ if (b != null) return b.byteValue();
+
+ byte result = getMethodTransactionType(m.getName(), m.getParameterTypes(), iface);
+
+ // provide default if method is not found in descriptor
+ if (result == MetaData.TX_UNKNOWN)
+ result = MetaData.TX_REQUIRED;
+
+ methodTx.put(m, new Byte(result));
+ return result;
+ }
+
+ public Collection getDepends()
+ {
+ Collection allDepends = new LinkedList(depends);
+ allDepends.addAll(getContainerConfiguration().getDepends());
+ return allDepends;
+ }
+
+ /**
+ * Checks meta data to obtain the Method Attributes of a bean's method:
+ * method attributes are read-only, idempotent and potentially other
+ * ones as well.
+ * These jboss-specific method attributes are described in jboss.xml
+ */
+ private MethodAttributes methodAttributesForMethod(String methodName)
+ {
+ if (methodName == null)
+ methodName = "*null*";
+
+ MethodAttributes ma =
+ (MethodAttributes)cachedMethodAttributes.get(methodName);
+
+ if (ma == null)
+ {
+ Iterator iterator = methodAttributes.iterator();
+ while (iterator.hasNext() && ma == null)
+ {
+ ma = (MethodAttributes)iterator.next();
+ if (!ma.patternMatches(methodName))
+ {
+ ma = null;
+ }
+ }
+ if (ma == null)
+ {
+ ma = MethodAttributes.kDefaultMethodAttributes;
+ }
+
+ cachedMethodAttributes.put(methodName, ma);
+ }
+ return ma;
+ }
+
+ /**
+ * Is this method a read-only method described in jboss.xml?
+ */
+ public boolean isMethodReadOnly(String methodName)
+ {
+ return methodAttributesForMethod(methodName).readOnly;
+ }
+
+ public boolean isMethodReadOnly(Method method)
+ {
+ if (method == null)
+ {
+ return false;
+ }
+ return methodAttributesForMethod(method.getName()).readOnly;
+ }
+
+ /**
+ * Get the transaction timeout for the method
+ */
+ public int getTransactionTimeout(String methodName)
+ {
+ return methodAttributesForMethod(methodName).txTimeout;
+ }
+
+ public int getTransactionTimeout(Method method)
+ {
+ if (method == null)
+ return 0;
+ return getTransactionTimeout(method.getName());
+ }
+
+ /**
+ * A somewhat tedious method that builds a Set<Principal> of the roles
+ * that have been assigned permission to execute the indicated method. The
+ * work performed is tedious because of the wildcard style of declaring
+ * method permission allowed in the ejb-jar.xml descriptor. This method is
+ * called by the Container.getMethodPermissions() when it fails to find the
+ * prebuilt set of method roles in its cache.
+ *
+ * @return The Set<Principal> for the application domain roles that
+ * caller principal's are to be validated against.
+ */
+ public Set getMethodPermissions(String methodName, Class[] params,
+ InvocationType iface)
+ {
+ Set result = new HashSet();
+ // First check the excluded method list as this takes priority over
+ // all other assignments
+ Iterator iterator = getExcludedMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ /* No one is allowed to execute this method so add a role that
+ fails to equate to any Principal or Principal name and return.
+ We don't return null to differentiate between an explicit
+ assignment of no access and no assignment information.
+ */
+ result.add(NobodyPrincipal.NOBODY_PRINCIPAL);
+ return result;
+ }
+ }
+
+ // Check the permissioned methods list
+ iterator = getPermissionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ /* If this is an unchecked method anyone can access it so
+ set the result set to a role that equates to any Principal or
+ Principal name and return.
+ */
+ if (m.isUnchecked())
+ {
+ result.clear();
+ result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ break;
+ }
+ // Else, add all roles
+ else
+ {
+ Iterator rolesIterator = m.getRoles().iterator();
+ while (rolesIterator.hasNext())
+ {
+ String roleName = (String)rolesIterator.next();
+ result.add(new SimplePrincipal(roleName));
+ }
+ }
+ }
+ }
+
+ if (this.isExcludeMissingMethods() == false)
+ {
+ // If no permissions were assigned to the method, anybody can access it
+ if (result.isEmpty())
+ {
+ result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
+ }
+ }
+
+ return result;
+ }
+
+ /** Check to see if there was a method-permission or exclude-list statement
+ * for the given method.
+ *
+ * @param methodName - the method name
+ * @param params - the method parameter signature
+ * @param iface - the method interface type
+ * @return true if a matching method permission exists, false if no match
+ */
+ public boolean hasMethodPermission(String methodName, Class[] params,
+ InvocationType iface)
+ {
+ // First check the excluded method list as this takes priority
+ Iterator iterator = getExcludedMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ return true;
+ }
+ }
+
+ // Check the permissioned methods list
+ iterator = getPermissionMethods();
+ while (iterator.hasNext())
+ {
+ MethodMetaData m = (MethodMetaData)iterator.next();
+ if (m.patternMatches(methodName, params, iface))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // Cluster configuration methods
+ public boolean isClustered()
+ {
+ return this.clustered;
+ }
+
+ public boolean isCallByValue()
+ {
+ return callByValue;
+ }
+
+ public boolean isExcludeMissingMethods()
+ {
+ return application.isExcludeMissingMethods();
+ }
+
+ public ClusterConfigMetaData getClusterConfigMetaData()
+ {
+ if (clusterConfig == null)
+ {
+ clusterConfig = getContainerConfiguration().getClusterConfigMetaData();
+ if (clusterConfig == null)
+ {
+ clusterConfig = new ClusterConfigMetaData();
+ }
+ /* All beans associated with a container are the same type
+ so this can be done more than once without harm */
+ clusterConfig.init(this);
+ }
+ return this.clusterConfig;
+ }
+
+ public IorSecurityConfigMetaData getIorSecurityConfigMetaData()
+ {
+ return iorSecurityConfig;
+ }
+
+ public boolean getExceptionRollback()
+ {
+ return exceptionRollback;
+ }
+
+ public boolean getTimerPersistence()
+ {
+ return timerPersistence;
+ }
+
+ /** Called to parse the ejb-jar.xml enterprise-beans child ejb elements
+ * @param element one of session/entity/message-driven
+ * @throws DeploymentException
+ */
+ public void importEjbJarXml(Element element)
+ throws DeploymentException
+ {
+ // set the ejb-name
+ ejbName = getElementContent(getUniqueChild(element, "ejb-name"));
+
+ // Set the interfaces classes for all types but MessageDriven
+ if (isMessageDriven() == false)
+ {
+ homeClass = getElementContent(getOptionalChild(element, "home"));
+ remoteClass = getElementContent(getOptionalChild(element, "remote"));
+ localHomeClass = getElementContent(getOptionalChild(element,
+ "local-home"));
+ localClass = getElementContent(getOptionalChild(element, "local"));
+ }
+ ejbClass = getElementContent(getUniqueChild(element, "ejb-class"));
+
+ // set the environment entries
+ Iterator iterator = getChildrenByTagName(element, "env-entry");
+
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element)iterator.next();
+
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // set the ejb references
+ iterator = getChildrenByTagName(element, "ejb-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element)iterator.next();
+
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // set the ejb local references
+ iterator = getChildrenByTagName(element, "ejb-local-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element)iterator.next();
+
+ EjbLocalRefMetaData ejbLocalRefMetaData = new EjbLocalRefMetaData();
+ ejbLocalRefMetaData.importEjbJarXml(ejbLocalRef);
+
+ ejbLocalReferences.put(ejbLocalRefMetaData.getName(),
+ ejbLocalRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element)iterator.next();
+ new ServiceRefDelegate().newServiceRefMetaData();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // set the security roles references
+ iterator = getChildrenByTagName(element, "security-role-ref");
+
+ while (iterator.hasNext())
+ {
+ Element secRoleRef = (Element)iterator.next();
+ SecurityRoleRefMetaData securityRoleRefMetaData = new SecurityRoleRefMetaData();
+ securityRoleRefMetaData.importEjbJarXml(secRoleRef);
+ securityRoleReferences.add(securityRoleRefMetaData);
+ }
+
+ // The security-identity element
+ Element securityIdentityElement = getOptionalChild(element,
+ "security-identity");
+ if (securityIdentityElement != null)
+ {
+ securityIdentity = new SecurityIdentityMetaData();
+ securityIdentity.importEjbJarXml(securityIdentityElement);
+ }
+
+ // set the resource references
+ iterator = getChildrenByTagName(element, "resource-ref");
+
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+
+ resourceReferences.put(resourceRefMetaData.getRefName(),
+ resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // set the message destination references
+ iterator = getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element)iterator.next();
+
+ MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
+ messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
+
+ messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
+ }
+ }
+
+ /** Called to parse the jboss.xml enterprise-beans child ejb elements
+ * @param element one of session/entity/message-driven
+ * @throws DeploymentException
+ */
+ public void importJbossXml(Element element) throws DeploymentException
+ {
+ // we must not set defaults here, this might never be called
+
+ // set the jndi name, (optional)
+ jndiName = getElementContent(getOptionalChild(element, "jndi-name"));
+
+ // set the JNDI name under with the local home interface should be
+ // bound (optional)
+ localJndiName = getElementContent(getOptionalChild(element, "local-jndi-name"));
+
+ // Determine if the bean should use by value call semantics
+ String callByValueElt = getElementContent(getOptionalChild(element, "call-by-value"), (callByValue ? "True" : "False"));
+ callByValue = callByValueElt.equalsIgnoreCase("True");
+
+ // set the configuration (optional)
+ configurationName = getElementContent(getOptionalChild(element, "configuration-name"));
+ if (configurationName != null && getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null)
+ {
+ throw new DeploymentException("configuration '" + configurationName + "' not found in standardjboss.xml or jboss.xml");
+ }
+
+ // Get the security proxy
+ securityProxy = getElementContent(getOptionalChild(element, "security-proxy"), securityProxy);
+
+ // Throw an exception when marked rollback with no exception thrown
+ exceptionRollback = MetaData.getOptionalChildBooleanContent(element, "exception-on-rollback", false);
+
+ // Whether to persist ejb timers across redeployments
+ timerPersistence = MetaData.getOptionalChildBooleanContent(element, "timer-persistence", true);
+
+ // update the resource references (optional)
+ Iterator iterator = getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)resourceReferences.get(resRefName);
+
+ if (resourceRefMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ resourceRefMetaData.importJbossXml(resourceRef);
+ }
+
+ // Set the resource-env-ref deployed jndi names
+ iterator = getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element)iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // update the message destination references (optional)
+ iterator = getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element)iterator.next();
+ String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name"));
+ MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData)messageDestinationReferences.get(messageDestinationRefName);
+ if (messageDestinationRefMetaData == null)
+ throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss.xml but not in ejb-jar.xml");
+ messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
+ }
+
+ // set the external ejb-references (optional)
+ iterator = getChildrenByTagName(element, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element)iterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+
+ //handle the ejb-local-ref elements
+ iterator = getChildrenByTagName(element, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element)iterator.next();
+ String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
+
+ EjbLocalRefMetaData ejbLocalRefMetaData = getEjbLocalRefByName(ejbLocalRefName);
+ if (ejbLocalRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ejbLocalRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element)iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // Get the security identity
+ Element securityIdentityElement = getOptionalChild(element, "security-identity");
+ if (securityIdentityElement != null)
+ {
+ if (securityIdentity == null)
+ throw new DeploymentException(ejbName + ", security-identity in jboss.xml has no match in ejb-jar.xml");
+ String runAsPrincipal = getElementContent(getUniqueChild(securityIdentityElement,
+ "run-as-principal"), securityIdentity.getRunAsPrincipalName());
+ securityIdentity.setRunAsPrincipalName(runAsPrincipal);
+ }
+
+ // Get the ejbTimeout caller identity
+ Element ejbTimeoutIdentityElement = getOptionalChild(element, "ejb-timeout-identity");
+ if (ejbTimeoutIdentityElement != null)
+ {
+ ejbTimeoutIdentity = new SecurityIdentityMetaData();
+ String runAsPrincipal = getElementContent(getUniqueChild(ejbTimeoutIdentityElement,
+ "run-as-principal"), null);
+ ejbTimeoutIdentity.setRunAsRoleName("ejbTimeout");
+ if( runAsPrincipal != null && runAsPrincipal.length() > 0 )
+ ejbTimeoutIdentity.setRunAsPrincipalName(runAsPrincipal);
+ else
+ ejbTimeoutIdentity.setUseCallerIdentity(true);
+ }
+
+ // Method attributes of the bean
+ Element mas = getOptionalChild(element, "method-attributes");
+ if (mas != null)
+ {
+ // read in the read-only methods
+ iterator = getChildrenByTagName(mas, "method");
+ while (iterator.hasNext())
+ {
+ MethodAttributes ma = new MethodAttributes();
+ Element maNode = (Element)iterator.next();
+ ma.pattern = getElementContent(getUniqueChild(maNode, "method-name"));
+ ma.readOnly = getOptionalChildBooleanContent(maNode, "read-only");
+ ma.idempotent = getOptionalChildBooleanContent(maNode, "idempotent");
+ String txTimeout = getOptionalChildContent(maNode, "transaction-timeout");
+ try
+ {
+ if (txTimeout != null && txTimeout.length() > 0)
+ ma.txTimeout = Integer.parseInt(txTimeout);
+ }
+ catch (Exception ignore)
+ {
+ log.debug("Ignoring transaction-timeout '" + txTimeout + "'", ignore);
+ }
+ methodAttributes.add(ma);
+ }
+ }
+
+ // Invokers
+ // If no invoker bindings have been defined they will be defined
+ // in EntityMetaData, or SessionMetaData
+ Element inv = getOptionalChild(element, "invoker-bindings");
+ if (inv != null)
+ {
+ // read in the read-only methods
+ iterator = getChildrenByTagName(inv, "invoker");
+ invokerBindings = new HashMap();
+ while (iterator.hasNext())
+ {
+ Element node = (Element)iterator.next();
+ String invokerBindingName = getUniqueChildContent(node, "invoker-proxy-binding-name");
+ String jndiBinding = getOptionalChildContent(node, "jndi-name");
+
+ if (jndiBinding == null)
+ {
+ jndiBinding = getJndiName(); // default to jndiName
+ }
+ invokerBindings.put(invokerBindingName, jndiBinding);
+
+ // set the external ejb-references (optional)
+ Iterator ejbrefiterator = getChildrenByTagName(node, "ejb-ref");
+ while (ejbrefiterator.hasNext())
+ {
+ Element ejbRef = (Element)ejbrefiterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml");
+ }
+ ejbRefMetaData.importJbossXml(invokerBindingName, ejbRef);
+ }
+ }
+ }
+
+ // Determine if the bean is to be deployed in the cluster (more
+ // advanced config will be added in the future)
+ String clusteredElt = getElementContent(getOptionalChild(element, "clustered"), (clustered ? "True" : "False"));
+ clustered = clusteredElt.equalsIgnoreCase("True");
+
+ Element clusterConfigElement = getOptionalChild(element, "cluster-config");
+ if (clusterConfigElement != null)
+ {
+ this.clusterConfig = new ClusterConfigMetaData();
+ clusterConfig.init(this);
+ clusterConfig.importJbossXml(clusterConfigElement);
+ }
+
+ //Get depends object names
+ for (Iterator dependsElements = getChildrenByTagName(element, "depends"); dependsElements.hasNext();)
+ {
+ Element dependsElement = (Element)dependsElements.next();
+ String dependsName = getElementContent(dependsElement);
+ depends.add(ObjectNameFactory.create(dependsName));
+ } // end of for ()
+
+ // ior-security-config optional element
+ Element iorSecurityConfigEl = getOptionalChild(element, "ior-security-config");
+ if (iorSecurityConfigEl != null)
+ {
+ iorSecurityConfig = new IorSecurityConfigMetaData(iorSecurityConfigEl);
+ }
+
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/ClientMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/ClientMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/ClientMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,326 @@
+/*
+ * 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.metadata;
+
+// $Id: ClientMetaData.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.net.URLClassLoader;
+
+/** The metdata data from a j2ee application-client.xml descriptor
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ * @version $Revision: 69712 $
+ */
+public class ClientMetaData
+{
+ /** The application-client/display-name */
+ private String displayName;
+ /** The location for the server side client context ENC bindings */
+ private String jndiName;
+ /** An ArrayList<EnvEntryMetaData> for the env-entry element(s) */
+ private ArrayList environmentEntries = new ArrayList();
+ /** A HashMap<String, EjbRefMetaData> for the ejb-ref element(s) */
+ private HashMap ejbReferences = new HashMap();
+ /** The HashMap<String, ServiceRefMetaData> service-ref element(s) info */
+ private HashMap<String,ServiceRefMetaData> serviceReferences = new HashMap<String,ServiceRefMetaData>();
+ /** A HashMap<String, ResourceRefMetaData> resource-ref element(s) info */
+ private HashMap resourceReferences = new HashMap();
+ /** A HashMap<String, ResourceEnvRefMetaData> resource-env-ref element(s) info */
+ private HashMap resourceEnvReferences = new HashMap();
+ /** A HashMap<String, ArrayList<ResourceEnvRefMetaData>> of
+ * message-destination-ref that resolve to a jndi-name via a message-destination
+ * via a message-destination-link
+ */
+ private HashMap resourceEnvReferenceLinks = new HashMap();
+ /** The JAAS callback handler */
+ private String callbackHandler;
+
+ /** The ClassLoader to load additional resources */
+ private URLClassLoader resourceCl;
+
+ /** Set the ClassLoader to load additional resources */
+ public void setResourceClassLoader(URLClassLoader resourceCl)
+ {
+ this.resourceCl = resourceCl;
+ }
+
+ /** The application-client/display-name
+ * @return application-client/display-name value
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ /** The location for the server side client context ENC bindings
+ * @return the JNDI name for the server side client context ENC bindings. This
+ * is either the jboss-client/jndi-name or the application-client/display-name
+ * value.
+ */
+ public String getJndiName()
+ {
+ String name = jndiName;
+ if( name == null )
+ name = displayName;
+ return name;
+ }
+
+ /**
+ * @return ArrayList<EnvEntryMetaData>
+ */
+ public ArrayList getEnvironmentEntries()
+ {
+ return environmentEntries;
+ }
+ /**
+ * @return HashMap<EjbRefMetaData>
+ */
+ public HashMap getEjbReferences()
+ {
+ return ejbReferences;
+ }
+ /**
+ * @return HashMap<ResourceRefMetaData>
+ */
+ public HashMap getResourceReferences()
+ {
+ return resourceReferences;
+ }
+ /**
+ * @return HashMap<ResourceEnvRefMetaData>
+ */
+ public HashMap getResourceEnvReferences()
+ {
+ return resourceEnvReferences;
+ }
+ /**
+ * @return The CallbackHandler if defined, null otherwise
+ */
+ public String getCallbackHandler()
+ {
+ return callbackHandler;
+ }
+ /**
+ * @return HashMap<ServiceRefMetaData>
+ */
+ public HashMap<String,ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public void importClientXml(Element element)
+ throws DeploymentException
+ {
+ displayName = MetaData.getOptionalChildContent(element, "display-name");
+
+ // set the environment entries
+ Iterator iterator = MetaData.getChildrenByTagName(element, "env-entry");
+
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element) iterator.next();
+
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // set the ejb references
+ iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
+
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // The callback-handler element
+ Element callbackElement = MetaData.getOptionalChild(element,
+ "callback-handler");
+ if (callbackElement != null)
+ {
+ callbackHandler = MetaData.getElementContent(callbackElement);
+ }
+
+ // set the resource references
+ iterator = MetaData.getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+
+ resourceReferences.put(resourceRefMetaData.getRefName(),
+ resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // Parse the message-destination-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ /* A message-destination-ref is linked to a jndi-name either via
+ the message-destination-ref/message-destination-ref-name mapping to
+ a jboss resource-env-ref/resource-env-ref-name if there is no
+ message-destination-link, or by the message-destination-link ->
+ message-destination/message-destination-name mapping to a jboss
+ resource-env-ref/resource-env-ref-name.
+ */
+ String refName = refMetaData.getRefName();
+ String link = refMetaData.getLink();
+ if( link != null )
+ {
+ ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(link);
+ if( linkedRefs == null )
+ {
+ linkedRefs = new ArrayList();
+ resourceEnvReferenceLinks.put(link, linkedRefs);
+ }
+ linkedRefs.add(refMetaData);
+ }
+ resourceEnvReferences.put(refName, refMetaData);
+ }
+ }
+
+ public void importJbossClientXml(Element element) throws DeploymentException
+ {
+ jndiName = MetaData.getOptionalChildContent(element, "jndi-name");
+
+ // Get the JNDI names of ejb-refs
+ Iterator iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ String ejbRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(element, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // Get the JNDI name binding for resource-refs
+ iterator = MetaData.getChildrenByTagName(element, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData resourceRefMetaData =
+ (ResourceRefMetaData) resourceReferences.get(resRefName);
+ if (resourceRefMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ resourceRefMetaData.importJbossXml(resourceRef);
+ }
+
+ // Get the JNDI name binding resource-env-refs
+ iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = MetaData.getElementContent(
+ MetaData.getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData =
+ (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ // Try the resourceEnvReferenceLinks
+ ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(resRefName);
+ if( linkedRefs != null )
+ {
+ for(int n = 0; n < linkedRefs.size(); n ++)
+ {
+ refMetaData = (ResourceEnvRefMetaData) linkedRefs.get(n);
+ refMetaData.importJbossXml(resourceRef);
+ }
+ }
+ else
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss-client.xml but not in application-client.xml");
+ }
+ }
+ else
+ {
+ refMetaData.importJbossXml(resourceRef);
+ }
+ }
+ }
+}
Property changes on: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/ClientMetaData.java
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/WebMetaData.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/WebMetaData.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/WebMetaData.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,1414 @@
+/*
+ * 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.metadata;
+
+// $Id: WebMetaData.java 74786 2008-06-18 10:21:59Z darran.lofthouse at jboss.com $
+
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+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 org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.security.RunAsIdentity;
+import org.jboss.security.SecurityRoleMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.w3c.dom.Element;
+
+/** A representation of the web.xml and jboss-web.xml deployment
+ * descriptors as used by the AbstractWebContainer web container integration
+ * support class.
+ *
+ * @see XmlLoadable
+ * @see org.jboss.web.AbstractWebContainer
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 74786 $
+ */
+public class WebMetaData extends MetaData
+{
+ private static Logger log = Logger.getLogger(WebMetaData.class);
+
+ /** The web.xml servlet <String, String> */
+ private HashMap servletClassNames = new HashMap();
+
+ /** The web.xml servlet-param <String,String> */
+ private HashMap servletParams = new HashMap();
+
+ /** The web.xml context-param <String,String> */
+ private HashMap contextParams = new HashMap();
+
+ /** The web.xml servlet-mapping <String, String> */
+ private HashMap servletMappings = new HashMap();
+
+ /** The web.xml resource-refs <String, String> */
+ private HashMap resourceReferences = new HashMap();
+
+ /** The web.xml resource-env-refs <String, String> */
+ private HashMap resourceEnvReferences = new HashMap();
+
+ /** The web.xml message-destination-refs <String, MessageDestinationRefMetaData> */
+ private HashMap messageDestinationReferences = new HashMap();
+
+ /** The web.xml message-destination <String, MessageDestinationMetaData> */
+ private HashMap messageDestinations = new HashMap();
+
+ /** web.xml env-entrys */
+ private ArrayList environmentEntries = new ArrayList();
+
+ /** web.xml security-constraint <WebSecurityMetaData> */
+ private ArrayList securityContraints = new ArrayList();
+
+ /** The HashMap<String, SecurityRoleMetaData> for the security-roles */
+ private HashMap securityRoles = new HashMap();
+
+ /** web.xml ejb-refs */
+ private HashMap ejbReferences = new HashMap();
+
+ /** web.xml ejb-local-refs */
+ private HashMap ejbLocalReferences = new HashMap();
+
+ /** The web.xml service-refs */
+ private HashMap<String, ServiceRefMetaData> serviceReferences = new HashMap<String, ServiceRefMetaData>();
+
+ /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
+ private HashMap securityRoleReferences = new HashMap();
+
+ /** The web.xml servlet/run-as <String servlet-name, String role> */
+ private HashMap runAsNames = new HashMap();
+
+ /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity> */
+ private HashMap runAsIdentity = new HashMap();
+
+ /** The web.xml distributable flag */
+ private boolean distributable = false;
+
+ /** The jboss-web.xml class-loading.java2ClassLoadingCompliance flag */
+ private boolean java2ClassLoadingCompliance = false;
+
+ /** The jboss-web.xml class-loading jboss class loader flag */
+ private boolean useJBossWebLoader = false;
+
+ /** The jboss-web.xml class-loading/loader-repository */
+ private LoaderRepositoryConfig loaderConfig;
+
+ /** The war context root as specified at the jboss-web.xml descriptor level. */
+ private String contextRoot;
+
+ /** The JACC context id for the container */
+ private String jaccContextID;
+
+ /** The jboss-web.xml server container virtual hosts the war should be deployed into */
+ private ArrayList virtualHosts = new ArrayList();
+
+ /** The jboss-web.xml JNDI name of the security domain implementation */
+ private String securityDomain;
+
+ /** JBAS-1824: Flag whether WebResourcePermission(url,null) needed for rolename '*' */
+ private boolean jaccRoleNameStar = false;
+
+ /** The jboss-web.xml securityDomain flushOnSessionInvalidation attribute */
+ private boolean flushOnSessionInvalidation;
+
+ /** A HashMap<String, String> for webservice description publish locations */
+ private HashMap wsdlPublishLocationMap = new HashMap();
+
+ /** True if this is a web service deployment */
+ private boolean webServiceDeployment;
+
+ /** The optional JBossWS config-name */
+ private String configName;
+
+ /** The optional JBossWS config-file */
+ private String configFile;
+
+ /** The web context class loader used to create the java:comp context */
+ private ClassLoader encLoader;
+
+ /** The web context class loader, used to create the ws4ee service endpoint */
+ private ClassLoader cxtLoader;
+
+ /** ArrayList<ObjectName> of the web app dependencies */
+ private ArrayList depends = new ArrayList();
+
+ public static final int SESSION_INVALIDATE_ACCESS = 0;
+
+ public static final int SESSION_INVALIDATE_SET_AND_GET = 1;
+
+ public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET = 2;
+
+ public static final int SESSION_INVALIDATE_SET = 3;
+
+ private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
+
+ public static final int REPLICATION_TYPE_SYNC = 0;
+
+ public static final int REPLICATION_TYPE_ASYNC = 1;
+
+ /**
+ * @deprecated Since JBoss3.2.6.
+ */
+ private int replicationType = REPLICATION_TYPE_SYNC;
+
+ /** Specify the session replication granularity level: session --- whole session level,
+ * attribute --- per attribute change, field --- fine grained user object level.
+ *
+ */
+ public static final int REPLICATION_GRANULARITY_SESSION = 0;
+
+ public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1;
+
+ public static final int REPLICATION_GRANULARITY_FIELD = 2;
+
+ private int replicationGranularity = REPLICATION_GRANULARITY_SESSION;
+
+ /**
+ * If the replication granularity is FIELD, specify whether to use batch mode
+ * for pojo replication or not.
+ */
+ private boolean replicationFieldBatchMode = true;
+
+ /** Should the context use session cookies or use default */
+ private int sessionCookies = SESSION_COOKIES_DEFAULT;
+
+ public static final int SESSION_COOKIES_DEFAULT = 0;
+
+ public static final int SESSION_COOKIES_ENABLED = 1;
+
+ public static final int SESSION_COOKIES_DISABLED = 2;
+
+ /** The ClassLoader to load additional resources */
+ private URLClassLoader resourceCl;
+
+ /** Set the ClassLoader to load additional resources */
+ public void setResourceClassLoader(URLClassLoader resourceCl)
+ {
+ this.resourceCl = resourceCl;
+ }
+
+ /** Return an iterator of the env-entry mappings.
+ @return Iterator of EnvEntryMetaData objects.
+ */
+ public Iterator getEnvironmentEntries()
+ {
+ return environmentEntries.iterator();
+ }
+
+ /**
+ *
+ * @param environmentEntries - Collection<EnvEntryMetaData>
+ */
+ public void setEnvironmentEntries(Collection environmentEntries)
+ {
+ this.environmentEntries.clear();
+ this.environmentEntries.addAll(environmentEntries);
+ }
+
+ /** Return an iterator of the ejb-ref mappings.
+ @return Iterator of EjbRefMetaData objects.
+ */
+ public Iterator getEjbReferences()
+ {
+ return ejbReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param ejbReferences - Map<String, EjbRefMetaData>
+ */
+ public void setEjbReferences(Map ejbReferences)
+ {
+ this.ejbReferences.clear();
+ this.ejbReferences.putAll(ejbReferences);
+ }
+
+ /** Return an iterator of the ejb-local-ref mappings.
+ @return Iterator of EjbLocalRefMetaData objects.
+ */
+ public Iterator getEjbLocalReferences()
+ {
+ return ejbLocalReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param ejbReferences - Map<String, EjbRefMetaData>
+ */
+ public void setEjbLocalReferences(Map ejbReferences)
+ {
+ this.ejbLocalReferences.clear();
+ this.ejbLocalReferences.putAll(ejbReferences);
+ }
+
+ /** Return an iterator of the resource-ref mappings.
+ @return Iterator of ResourceRefMetaData objects.
+ */
+ public Iterator getResourceReferences()
+ {
+ return resourceReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param resourceReferences - Map<String, ResourceRefMetaData>
+ */
+ public void setResourceReferences(Map resourceReferences)
+ {
+ this.resourceReferences.clear();
+ this.resourceReferences.putAll(resourceReferences);
+ }
+
+ /** Return an iterator of the resource-ref mappings.
+ @return Iterator of ResourceEnvRefMetaData objects.
+ */
+ public Iterator getResourceEnvReferences()
+ {
+ return resourceEnvReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param resourceReferences - Map<String, ResourceEnvRefMetaData>
+ */
+ public void setResourceEnvReferences(Map resourceReferences)
+ {
+ this.resourceEnvReferences.clear();
+ this.resourceEnvReferences.putAll(resourceReferences);
+ }
+
+ /**
+ * Return an iterator of message-destination-refs.
+ *
+ * @return Iterator of MessageDestinationRefMetaData objects.
+ */
+ public Iterator getMessageDestinationReferences()
+ {
+ return messageDestinationReferences.values().iterator();
+ }
+
+ /**
+ *
+ * @param messageDestinationReferences - Map<String, MessageDestinationRefMetaData>
+ */
+ public void setMessageDestinationReferences(Map messageDestinationReferences)
+ {
+ this.messageDestinationReferences.clear();
+ this.messageDestinationReferences.putAll(messageDestinationReferences);
+ }
+
+ /**
+ * Get a message destination metadata
+ *
+ * @param name the name of the message destination
+ * @return the message destination metadata
+ */
+ public MessageDestinationMetaData getMessageDestination(String name)
+ {
+ return (MessageDestinationMetaData) messageDestinations.get(name);
+ }
+
+ /**
+ *
+ * @param messageDestinations - Map<String, MessageDestinationMetaData>
+ */
+ public void setMessageDestination(Map messageDestinations)
+ {
+ this.messageDestinations.clear();
+ this.messageDestinations.putAll(messageDestinations);
+ }
+
+ public Map<String, ServiceRefMetaData> getServiceReferences()
+ {
+ return serviceReferences;
+ }
+
+ public void setServiceReferences(Map<String, ServiceRefMetaData> serviceReferences)
+ {
+ this.serviceReferences.clear();
+ this.serviceReferences.putAll(serviceReferences);
+ }
+
+ /** This the the jboss-web.xml descriptor context-root and it
+ *is only meaningful if a war is deployed outside of an ear.
+ */
+ public String getContextRoot()
+ {
+ return contextRoot;
+ }
+
+ public void setContextRoot(String contextRoot)
+ {
+ this.contextRoot = contextRoot;
+ }
+
+ public String getConfigFile()
+ {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile)
+ {
+ this.configFile = configFile;
+ }
+
+ public String getConfigName()
+ {
+ return configName;
+ }
+
+ public void setConfigName(String configName)
+ {
+ this.configName = configName;
+ }
+
+ /** Get the optional wsdl publish location from jboss-web.xml. */
+ public String getWsdlPublishLocationByName(String name)
+ {
+ return (String) wsdlPublishLocationMap.get(name);
+ }
+
+ /**
+ *
+ * @param wsdlPublishLocationMap - Map<String, String>
+ */
+ public void setWsdlPublishLocationMap(Map wsdlPublishLocationMap)
+ {
+ this.wsdlPublishLocationMap.clear();
+ this.wsdlPublishLocationMap.putAll(wsdlPublishLocationMap);
+ }
+
+ public boolean isWebServiceDeployment()
+ {
+ return webServiceDeployment;
+ }
+
+ public void setWebServiceDeployment(boolean webServiceDeployment)
+ {
+ this.webServiceDeployment = webServiceDeployment;
+ }
+
+ public String getJaccContextID()
+ {
+ return jaccContextID;
+ }
+
+ public void setJaccContextID(String jaccContextID)
+ {
+ this.jaccContextID = jaccContextID;
+ }
+
+ /** Return the optional security-domain jboss-web.xml element.
+ @return The jndiName of the security manager implementation that is
+ responsible for security of the web application. May be null if
+ there was no security-domain specified in the jboss-web.xml
+ descriptor.
+ */
+ public String getSecurityDomain()
+ {
+ return securityDomain;
+ }
+
+ /** Set the security domain for this web application
+ */
+ public void setSecurityDomain(String securityDomain)
+ {
+ this.securityDomain = securityDomain;
+ }
+
+ /**
+ * JBAS-1824: Specify whether a WebResourcePermission(url,null)
+ * needs to be generated by the container
+ * @return
+ */
+ public boolean isJaccRoleNameStar()
+ {
+ return jaccRoleNameStar;
+ }
+
+ /**
+ * JBAS-1824: Specify whether a WebResourcePermission(url,null)
+ * needs to be generated by the container
+ * @return
+ */
+ public void setJaccRoleNameStar(boolean jaccRoleNameStar)
+ {
+ this.jaccRoleNameStar = jaccRoleNameStar;
+ }
+
+ /** The flag indicating whether the associated security domain cache
+ * should be flushed when the session is invalidated.
+ * @return true if the flush should occur, false otherwise.
+ */
+ public boolean isFlushOnSessionInvalidation()
+ {
+ return flushOnSessionInvalidation;
+ }
+
+ /** The flag indicating whether the associated security domain cache
+ * should be flushed when the session is invalidated.
+ * @param flag - true if the flush should occur, false otherwise.
+ */
+ public void setFlushOnSessionInvalidation(boolean flag)
+ {
+ this.flushOnSessionInvalidation = flag;
+ }
+
+ /** Get the security-constraint settings
+ */
+ public Iterator getSecurityContraints()
+ {
+ return securityContraints.iterator();
+ }
+
+ /**
+ *
+ * @param securityContraints - Collection<WebSecurityMetaData>
+ */
+ public void setSecurityConstraints(Collection securityContraints)
+ {
+ this.securityContraints.clear();
+ this.securityContraints.addAll(securityContraints);
+ }
+
+ /**
+ * @return <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
+ */
+ public Map getSecurityRoleRefs()
+ {
+ return this.securityRoleReferences;
+ }
+
+ /**
+ *
+ * @param servletName
+ * @return List<SecurityRoleRefMetaData> for the given servlet name
+ */
+ public List getSecurityRoleRefs(String servletName)
+ {
+ List roles = (List) this.securityRoleReferences.get(servletName);
+ return roles;
+ }
+
+ /**
+ *
+ * @param securityRoleReferences - <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
+ */
+ public void setSecurityRoleReferences(Map securityRoleReferences)
+ {
+ this.securityRoleReferences.clear();
+ this.securityRoleReferences.putAll(securityRoleReferences);
+ }
+
+ /**
+ * Get the security-role names from the web.xml descriptor
+ * @return Set<String> of the security-role names from the web.xml
+ */
+ public Set getSecurityRoleNames()
+ {
+ return new HashSet(securityRoles.keySet());
+ }
+
+ /** Get the optional map of security role/user mapping.
+ * @return Map<String, SecurityRoleMetaData>
+ */
+ public Map getSecurityRoles()
+ {
+ return new HashMap(securityRoles);
+ }
+
+ /**
+ *
+ * @param securityRoles - Map<String, SecurityRoleMetaData>
+ */
+ public void setSecurityRoles(Map securityRoles)
+ {
+ this.securityRoles.clear();
+ this.securityRoles.putAll(securityRoles);
+ }
+
+ /**
+ *
+ * @param userName
+ * @return Set<String>
+ */
+ public Set getSecurityRoleNamesByPrincipal(String userName)
+ {
+ HashSet roleNames = new HashSet();
+ Iterator it = securityRoles.values().iterator();
+ while (it.hasNext())
+ {
+ SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it.next();
+ if (srMetaData.getPrincipals().contains(userName))
+ roleNames.add(srMetaData.getRoleName());
+ }
+ return roleNames;
+ }
+
+ /**
+ * Access the RunAsIdentity associated with the given servlet
+ * @param servletName - the servlet-name from the web.xml
+ * @return RunAsIdentity for the servet if one exists, null otherwise
+ */
+ public RunAsIdentity getRunAsIdentity(String servletName)
+ {
+ RunAsIdentity runAs = (RunAsIdentity) runAsIdentity.get(servletName);
+ if (runAs == null)
+ {
+ // Check for a web.xml run-as only specification
+ synchronized (runAsIdentity)
+ {
+ String roleName = (String) runAsNames.get(servletName);
+ if (roleName != null)
+ {
+ runAs = new RunAsIdentity(roleName, null);
+ runAsIdentity.put(servletName, runAs);
+ }
+ }
+ }
+ return runAs;
+ }
+
+ /**
+ *
+ * @return servlet/run-as <String servlet-name, RunAsIdentity>
+ */
+ public Map getRunAsIdentity()
+ {
+ return runAsIdentity;
+ }
+
+ /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity>
+ */
+ public void setRunAsIdentity(Map runAsIdentity)
+ {
+ this.runAsIdentity.clear();
+ this.runAsIdentity.putAll(runAsIdentity);
+ }
+
+ /**
+ * Get the servlet-name values from the web.xml descriptor
+ * @return Set<String> of the servlet-names from the servlet-mappings
+ */
+ public HashMap getServletMappings()
+ {
+ return servletMappings;
+ }
+
+ /** The web.xml servlet-mapping */
+ /**
+ * servlet-mapping/serlvet-name to url-pattern mapping
+ * @param servletMappings - Map<String, String>
+ */
+ public void setServletMappings(Map servletMappings)
+ {
+ this.servletMappings.clear();
+ this.servletMappings.putAll(servletMappings);
+ }
+
+ /**
+ * Get the servlet-name values from the web.xml descriptor
+ * @return Set<String> of the servlet-names from the servlet-mappings
+ */
+ public Set getServletNames()
+ {
+ return new HashSet(servletMappings.keySet());
+ }
+
+ /**
+ <<<<<<< .working
+ =======
+ * Get the init parameter map for a servlet or an empty map if there are none.
+ */
+ public Map getServletParams(String servletName)
+ {
+ Map params = (Map) servletParams.get(servletName);
+ if (params == null)
+ {
+ params = new HashMap();
+ servletParams.put(servletName, params);
+ }
+ return params;
+ }
+
+ /**
+ >>>>>>> .merge-right.r68814
+ * Get the servlet-name/servlet-class mapping from the web.xml descriptor
+ * @return Map<String, String> of the servlet-name/servlet-class mapping from web.xml
+ */
+ public Map getServletClassMap()
+ {
+ return new HashMap(servletClassNames);
+ }
+
+ /**
+ * Merge the security role/principal mapping defined in jboss-web.xml
+ * with the one defined at jboss-app.xml.
+ */
+ public void mergeSecurityRoles(Map applRoles)
+ {
+ Iterator it = applRoles.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ String roleName = (String) entry.getKey();
+ SecurityRoleMetaData appRole = (SecurityRoleMetaData) entry.getValue();
+ SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
+ if (srMetaData != null)
+ {
+ Set principalNames = appRole.getPrincipals();
+ srMetaData.addPrincipalNames(principalNames);
+ }
+ else
+ {
+ securityRoles.put(roleName, entry.getValue());
+ }
+ }
+ }
+
+ /** The servlet container virtual host the war should be deployed into. If
+ null then the servlet container default host should be used.
+ */
+ public Iterator getVirtualHosts()
+ {
+ return virtualHosts.iterator();
+ }
+
+ /**
+ *
+ * @param virtualHosts - Collection<String>
+ */
+ public void setVirtualHosts(Collection virtualHosts)
+ {
+ this.virtualHosts.clear();
+ this.virtualHosts.addAll(virtualHosts);
+ }
+
+ /**
+ The distributable flag.
+ @return true if the web-app is marked distributable
+ */
+ public boolean getDistributable()
+ {
+ return distributable;
+ }
+
+ /**
+ * Mark the web-app as distributable
+ * @param distributable - true for distributable
+ */
+ public void setDistributable(boolean distributable)
+ {
+ this.distributable = distributable;
+ }
+
+ /** Access the web application depends
+ * @return Iterator of JMX ObjectNames the web app depends on.
+ */
+ public Collection getDepends()
+ {
+ return depends;
+ }
+
+ /**
+ @param depends - Collection<ObjectName> of the web app dependencies
+ */
+ public void setDepends(Collection depends)
+ {
+ this.depends.clear();
+ this.depends.addAll(depends);
+ }
+
+ /** A 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
+ */
+ public boolean getJava2ClassLoadingCompliance()
+ {
+ return java2ClassLoadingCompliance;
+ }
+
+ public void setJava2ClassLoadingCompliance(boolean flag)
+ {
+ java2ClassLoadingCompliance = flag;
+ }
+
+ public boolean isUseJBossWebLoader()
+ {
+ return useJBossWebLoader;
+ }
+
+ public void setUseJBossWebLoader(boolean flag)
+ {
+ useJBossWebLoader = flag;
+ }
+
+ public LoaderRepositoryConfig getLoaderConfig()
+ {
+ return loaderConfig;
+ }
+
+ public void setLoaderConfig(LoaderRepositoryConfig loaderConfig)
+ {
+ this.loaderConfig = loaderConfig;
+ }
+
+ public ClassLoader getENCLoader()
+ {
+ return encLoader;
+ }
+
+ public void setENCLoader(ClassLoader encLoader)
+ {
+ this.encLoader = encLoader;
+ }
+
+ public ClassLoader getContextLoader()
+ {
+ return cxtLoader;
+ }
+
+ /** Make sure this is called during performDeploy */
+ public void setContextLoader(ClassLoader cxtLoader)
+ {
+ this.cxtLoader = cxtLoader;
+ }
+
+ public int getSessionCookies()
+ {
+ return this.sessionCookies;
+ }
+
+ public void setSessionCookies(int sessionCookies)
+ {
+ this.sessionCookies = sessionCookies;
+ }
+
+ public int getInvalidateSessionPolicy()
+ {
+ return this.invalidateSessionPolicy;
+ }
+
+ public void setInvalidateSessionPolicy(int invalidateSessionPolicy)
+ {
+ this.invalidateSessionPolicy = invalidateSessionPolicy;
+ }
+
+ public int getReplicationType()
+ {
+ return replicationType;
+ }
+
+ public int getReplicationGranularity()
+ {
+ return replicationGranularity;
+ }
+
+ public void setReplicationGranularity(int replicationGranularity)
+ {
+ this.replicationGranularity = replicationGranularity;
+ }
+
+ public boolean getReplicationFieldBatchMode()
+ {
+ return replicationFieldBatchMode;
+ }
+
+ public void importXml(Element element) throws DeploymentException
+ {
+ String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
+ if (rootTag.equals("web-app"))
+ {
+ importWebXml(element);
+ }
+ else if (rootTag.equals("jboss-web"))
+ {
+ importJBossWebXml(element);
+ }
+ }
+
+ /** Parse the elements of the web-app element used by the integration layer.
+ */
+ protected void importWebXml(Element webApp) throws DeploymentException
+ {
+ // Parse the web-app/servlet/security-role-ref + run-as elements
+ Iterator iterator = getChildrenByTagName(webApp, "servlet");
+ while (iterator.hasNext())
+ {
+ Element servlet = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
+ String servletClass = getElementContent(getOptionalChild(servlet, "servlet-class"));
+ if (servletClass != null)
+ {
+ servletClassNames.put(servletName, servletClass);
+ }
+
+ Iterator initParams = getChildrenByTagName(servlet, "init-param");
+ while (initParams.hasNext())
+ {
+ Element param = (Element) initParams.next();
+ String paramName = getElementContent(getUniqueChild(param, "param-name"));
+ String paramValue = getElementContent(getUniqueChild(param, "param-value"));
+
+ if (null == servletParams.get(servletName))
+ {
+ servletParams.put(servletName, new HashMap());
+ }
+
+ ((Map) servletParams.get(servletName)).put(paramName, paramValue);
+ }
+
+ Iterator roleRefs = getChildrenByTagName(servlet, "security-role-ref");
+ ArrayList roleNames = new ArrayList();
+ while (roleRefs.hasNext())
+ {
+ Element roleRefElem = (Element) roleRefs.next();
+ SecurityRoleRefMetaData roleRef = new SecurityRoleRefMetaData();
+ roleRef.importEjbJarXml(roleRefElem);
+ roleNames.add(roleRef);
+ }
+ securityRoleReferences.put(servletName, roleNames);
+
+ // Check for a run-as/role-name
+ Element runAs = getOptionalChild(servlet, "run-as");
+ if (runAs != null)
+ {
+ String runAsName = getElementContent(getOptionalChild(runAs, "role-name"));
+ runAsNames.put(servletName, runAsName);
+ }
+ }
+
+ // Parse the web-app/context-param elements
+ iterator = getChildrenByTagName(webApp, "context-param");
+ while (iterator.hasNext())
+ {
+ Element contextParam = (Element) iterator.next();
+ String paramName = getElementContent(getUniqueChild(contextParam, "param-name"));
+ String paramValue = getElementContent(getUniqueChild(contextParam, "param-value"));
+ contextParams.put(paramName, paramValue);
+ }
+
+ // Parse the web-app/servlet-mapping elements
+ iterator = getChildrenByTagName(webApp, "servlet-mapping");
+ while (iterator.hasNext())
+ {
+ Element servletMapping = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servletMapping, "servlet-name"));
+ String urlPattern = getElementContent(getUniqueChild(servletMapping, "url-pattern"));
+ servletMappings.put(servletName, urlPattern);
+ }
+
+ // Parse the web-app/resource-ref elements
+ iterator = getChildrenByTagName(webApp, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
+ resourceRefMetaData.importEjbJarXml(resourceRef);
+ resourceReferences.put(resourceRefMetaData.getRefName(), resourceRefMetaData);
+ }
+
+ // Parse the resource-env-ref elements
+ iterator = getChildrenByTagName(webApp, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
+ refMetaData.importEjbJarXml(resourceRef);
+ resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
+ }
+
+ // set the message destination references
+ iterator = getChildrenByTagName(webApp, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element) iterator.next();
+ MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData();
+ messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef);
+ messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData);
+ }
+
+ // set the message destinations (optional)
+ iterator = getChildrenByTagName(webApp, "message-destination");
+ while (iterator.hasNext())
+ {
+ Element messageDestination = (Element) iterator.next();
+ try
+ {
+ MessageDestinationMetaData messageDestinationMetaData = new MessageDestinationMetaData();
+ messageDestinationMetaData.importEjbJarXml(messageDestination);
+ messageDestinations.put(messageDestinationMetaData.getName(), messageDestinationMetaData);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
+ }
+ }
+
+ // Parse the web-app/env-entry elements
+ iterator = getChildrenByTagName(webApp, "env-entry");
+ while (iterator.hasNext())
+ {
+ Element envEntry = (Element) iterator.next();
+ EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
+ envEntryMetaData.importEjbJarXml(envEntry);
+ environmentEntries.add(envEntryMetaData);
+ }
+
+ // Get the security-constraints
+ iterator = getChildrenByTagName(webApp, "security-constraint");
+ while (iterator.hasNext())
+ {
+ Element contraints = (Element) iterator.next();
+ WebSecurityMetaData wsmd = new WebSecurityMetaData();
+ securityContraints.add(wsmd);
+ // Process the web-resource-collections
+ Iterator iter2 = getChildrenByTagName(contraints, "web-resource-collection");
+ while (iter2.hasNext())
+ {
+ Element wrcElement = (Element) iter2.next();
+ Element wrName = getUniqueChild(wrcElement, "web-resource-name");
+ String name = getElementContent(wrName);
+ WebSecurityMetaData.WebResourceCollection wrc = wsmd.addWebResource(name);
+ Iterator iter21 = getChildrenByTagName(wrcElement, "url-pattern");
+ while (iter21.hasNext())
+ {
+ Element urlPattern = (Element) iter21.next();
+ String pattern = getElementContent(urlPattern);
+ wrc.addPattern(pattern);
+ }
+
+ Iterator iter22 = getChildrenByTagName(wrcElement, "http-method");
+ while (iter22.hasNext())
+ {
+ Element httpMethod = (Element) iter22.next();
+ String method = getElementContent(httpMethod);
+ wrc.addHttpMethod(method);
+ }
+ }
+
+ // Process the auth-constraints
+ Element authContraint = getOptionalChild(contraints, "auth-constraint");
+ if (authContraint != null)
+ {
+ Iterator iter3 = getChildrenByTagName(authContraint, "role-name");
+ while (iter3.hasNext())
+ {
+ Element roleName = (Element) iter3.next();
+ String name = getElementContent(roleName);
+ wsmd.addRole(name);
+ }
+ if (wsmd.getRoles().size() == 0)
+ wsmd.setExcluded(true);
+ }
+ else
+ {
+ wsmd.setUnchecked(true);
+ }
+
+ // Process the user-data-constraint
+ Element userData = getOptionalChild(contraints, "user-data-constraint");
+ if (userData != null)
+ {
+ Element transport = getUniqueChild(userData, "transport-guarantee");
+ String type = getElementContent(transport);
+ wsmd.setTransportGuarantee(type);
+ }
+ }
+
+ // Get the web-app/security-role elements (optional)
+ iterator = getChildrenByTagName(webApp, "security-role");
+ while (iterator.hasNext())
+ {
+ Element securityRole = (Element) iterator.next();
+ String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
+ securityRoles.put(roleName, new SecurityRoleMetaData(roleName));
+ }
+
+ // Parse the web-app/ejb-ref elements
+ iterator = getChildrenByTagName(webApp, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+ ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the web-app/ejb-local-ref elements
+ iterator = getChildrenByTagName(webApp, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ EjbLocalRefMetaData ejbRefMetaData = new EjbLocalRefMetaData();
+ ejbRefMetaData.importEjbJarXml(ejbRef);
+ ejbLocalReferences.put(ejbRefMetaData.getName(), ejbRefMetaData);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(webApp, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ ServiceRefMetaData refMetaData = new ServiceRefDelegate().newServiceRefMetaData();
+ refMetaData.importStandardXml(serviceRef);
+ serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+ }
+
+ // Is the web-app marked distributable?
+ iterator = getChildrenByTagName(webApp, "distributable");
+ if (iterator.hasNext())
+ {
+ distributable = true;
+ }
+ }
+
+ /** Parse the elements of the jboss-web element used by the integration layer.
+ */
+ protected void importJBossWebXml(Element jbossWeb) throws DeploymentException
+ {
+ // Parse the jboss-web/root-context element
+ Element contextRootElement = getOptionalChild(jbossWeb, "context-root");
+ if (contextRootElement != null)
+ contextRoot = getElementContent(contextRootElement);
+
+ // Parse the jboss-web/security-domain element
+ Element securityDomainElement = getOptionalChild(jbossWeb, "security-domain");
+ if (securityDomainElement != null)
+ {
+ securityDomain = getElementContent(securityDomainElement);
+ // Check the flushOnSessionInvalidation attribute
+ Boolean flag = Boolean.valueOf(securityDomainElement.getAttribute("flushOnSessionInvalidation"));
+ flushOnSessionInvalidation = flag.booleanValue();
+ }
+
+ //Parse the jboss-web/jacc-star-role-allow element
+ Element jaccStarRoleElement = getOptionalChild(jbossWeb, "jacc-star-role-allow");
+ if (jaccStarRoleElement != null)
+ {
+ jaccRoleNameStar = "true".equalsIgnoreCase(getElementContent(jaccStarRoleElement));
+ }
+
+ // Parse the jboss-web/virtual-host elements
+ for (Iterator virtualHostElements = getChildrenByTagName(jbossWeb, "virtual-host"); virtualHostElements.hasNext();)
+ {
+ Element virtualHostElement = (Element) virtualHostElements.next();
+ String virtualHostName = getElementContent(virtualHostElement);
+ virtualHosts.add(virtualHostName);
+ } // end of for ()
+
+ // Parse the jboss-web/resource-ref elements
+ Iterator iterator = getChildrenByTagName(jbossWeb, "resource-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
+ ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-ref " + resRefName + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // Parse the jboss-web/resource-env-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "resource-env-ref");
+ while (iterator.hasNext())
+ {
+ Element resourceRef = (Element) iterator.next();
+ String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
+ ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("resource-env-ref " + resRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJbossXml(resourceRef);
+ }
+
+ // update the message destination references (optional)
+ iterator = getChildrenByTagName(jbossWeb, "message-destination-ref");
+ while (iterator.hasNext())
+ {
+ Element messageDestinationRef = (Element) iterator.next();
+ String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef,
+ "message-destination-ref-name"));
+ MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences
+ .get(messageDestinationRefName);
+ if (messageDestinationRefMetaData == null)
+ throw new DeploymentException("message-destination-ref " + messageDestinationRefName
+ + " found in jboss-web.xml but not in web.xml");
+ messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
+ }
+
+ // set the message destinations (optional)
+ iterator = getChildrenByTagName(jbossWeb, "message-destination");
+ while (iterator.hasNext())
+ {
+ Element messageDestination = (Element) iterator.next();
+ try
+ {
+ String messageDestinationName = getUniqueChildContent(messageDestination, "message-destination-name");
+ MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations
+ .get(messageDestinationName);
+ if (messageDestinationMetaData == null)
+ throw new DeploymentException("message-destination " + messageDestinationName
+ + " found in jboss-web.xml but not in web.xml");
+ messageDestinationMetaData.importJbossXml(messageDestination);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Error in web.xml " + "for message destination: " + t.getMessage());
+ }
+ }
+
+ // set the security roles (optional)
+ iterator = getChildrenByTagName(jbossWeb, "security-role");
+ while (iterator.hasNext())
+ {
+ Element securityRole = (Element) iterator.next();
+ String roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
+ SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData) securityRoles.get(roleName);
+ if (securityRoleMetaData == null)
+ throw new DeploymentException("Security role '" + roleName + "' defined in jboss-web.xml"
+ + " is not defined in web.xml");
+
+ Iterator itPrincipalNames = getChildrenByTagName(securityRole, "principal-name");
+ while (itPrincipalNames.hasNext())
+ {
+ String principalName = getElementContent((Element) itPrincipalNames.next());
+ securityRoleMetaData.addPrincipalName(principalName);
+ }
+ }
+
+ // Parse the jboss-web/ejb-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "ejb-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbRef = (Element) iterator.next();
+ String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
+ EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
+ if (ejbRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss-web.xml but not in web.xml");
+ }
+ ejbRefMetaData.importJbossXml(ejbRef);
+ }
+
+ // Parse the jboss-web/ejb-local-ref elements
+ iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref");
+ while (iterator.hasNext())
+ {
+ Element ejbLocalRef = (Element) iterator.next();
+ String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
+ EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences.get(ejbLocalRefName);
+ if (ejbLocalRefMetaData == null)
+ {
+ throw new DeploymentException("ejb-local-ref " + ejbLocalRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
+ }
+
+ // Parse the service-ref elements
+ iterator = MetaData.getChildrenByTagName(jbossWeb, "service-ref");
+ while (iterator.hasNext())
+ {
+ Element serviceRef = (Element) iterator.next();
+ String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
+ ServiceRefMetaData refMetaData = (ServiceRefMetaData) serviceReferences.get(serviceRefName);
+ if (refMetaData == null)
+ {
+ throw new DeploymentException("service-ref " + serviceRefName
+ + " found in jboss-web.xml but not in web.xml");
+ }
+ refMetaData.importJBossXml(serviceRef);
+ }
+
+ // WebserviceDescriptions
+ iterator = getChildrenByTagName(jbossWeb, "webservice-description");
+ while (iterator.hasNext())
+ {
+ Element wsd = (Element) iterator.next();
+ String wsdName = getElementContent(getUniqueChild(wsd, "webservice-description-name"));
+ configName = MetaData.getOptionalChildContent(wsd, "config-name");
+ configFile = MetaData.getOptionalChildContent(wsd, "config-file");
+ String wsdlPublishLocation = getOptionalChildContent(wsd, "wsdl-publish-location");
+ wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation);
+ }
+
+ // Parse the jboss-web/depends elements
+ for (Iterator dependsElements = getChildrenByTagName(jbossWeb, "depends"); dependsElements.hasNext();)
+ {
+ Element dependsElement = (Element) dependsElements.next();
+ String dependsName = getElementContent(dependsElement);
+ depends.add(ObjectNameFactory.create(dependsName));
+ } // end of for ()
+
+ // Parse the jboss-web/use-session-cookies element
+ iterator = getChildrenByTagName(jbossWeb, "use-session-cookies");
+ if (iterator.hasNext())
+ {
+ Element useCookiesElement = (Element) iterator.next();
+ String useCookiesElementContent = getElementContent(useCookiesElement);
+ Boolean useCookies = Boolean.valueOf(useCookiesElementContent);
+
+ if (useCookies.booleanValue())
+ {
+ sessionCookies = SESSION_COOKIES_ENABLED;
+ }
+ else
+ {
+ sessionCookies = SESSION_COOKIES_DISABLED;
+ }
+ }
+
+ // Parse the jboss-web/session-replication element
+
+ Element sessionReplicationRootElement = getOptionalChild(jbossWeb, "replication-config");
+ if (sessionReplicationRootElement != null)
+ {
+ // manage "replication-trigger" first ...
+ //
+ Element replicationTriggerElement = getOptionalChild(sessionReplicationRootElement, "replication-trigger");
+ if (replicationTriggerElement != null)
+ {
+ String repMethod = getElementContent(replicationTriggerElement);
+ if ("SET_AND_GET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET;
+ else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
+ else if ("SET".equalsIgnoreCase(repMethod))
+ this.invalidateSessionPolicy = SESSION_INVALIDATE_SET;
+ else
+ throw new DeploymentException("replication-trigger value set to a non-valid value: '" + repMethod
+ + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml");
+ }
+
+ // ... then manage "replication-type".
+ //
+ Element replicationTypeElement = getOptionalChild(sessionReplicationRootElement, "replication-type");
+ if (replicationTypeElement != null)
+ {
+ String repType = getElementContent(replicationTypeElement);
+ if ("SYNC".equalsIgnoreCase(repType))
+ this.replicationType = REPLICATION_TYPE_SYNC;
+ else if ("ASYNC".equalsIgnoreCase(repType))
+ this.replicationType = REPLICATION_TYPE_ASYNC;
+ else
+ throw new DeploymentException("replication-type value set to a non-valid value: '" + repType
+ + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml");
+ }
+
+ // ... then manage "replication-type".
+ //
+ Element replicationGranularityElement = MetaData.getOptionalChild(sessionReplicationRootElement,
+ "replication-granularity");
+ if (replicationGranularityElement != null)
+ {
+ String repType = MetaData.getElementContent(replicationGranularityElement);
+ if ("SESSION".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_SESSION;
+ else if ("ATTRIBUTE".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE;
+ else if ("FIELD".equalsIgnoreCase(repType))
+ this.replicationGranularity = REPLICATION_GRANULARITY_FIELD;
+ else
+ throw new DeploymentException("replication-granularity value set to a non-valid value: '" + repType
+ + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml");
+ }
+
+ Element batchModeElement = MetaData.getOptionalChild(sessionReplicationRootElement,
+ "replication-field-batch-mode");
+ if (batchModeElement != null)
+ {
+ Boolean flag = Boolean.valueOf(MetaData.getElementContent(batchModeElement));
+ replicationFieldBatchMode = flag.booleanValue();
+ }
+ }
+
+ // Check for a war level class loading config
+ Element classLoading = MetaData.getOptionalChild(jbossWeb, "class-loading");
+ if (classLoading != null)
+ {
+ String flagString = classLoading.getAttribute("java2ClassLoadingCompliance");
+ if (flagString.length() == 0)
+ flagString = "true";
+ boolean flag = Boolean.valueOf(flagString).booleanValue();
+ setJava2ClassLoadingCompliance(flag);
+ // Check for a loader-repository for scoping
+ Element loader = MetaData.getOptionalChild(classLoading, "loader-repository");
+ if (loader != null)
+ {
+ useJBossWebLoader = true;
+ try
+ {
+ loaderConfig = LoaderRepositoryFactory.parseRepositoryConfig(loader);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+ }
+
+ // Parse the jboss-web/servlet elements
+ iterator = getChildrenByTagName(jbossWeb, "servlet");
+ while (iterator.hasNext())
+ {
+ Element servlet = (Element) iterator.next();
+ String servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
+ String principalName = getOptionalChildContent(servlet, "run-as-principal");
+ // Get the web.xml run-as primary role
+ String webXmlRunAs = (String) runAsNames.get(servletName);
+ if (principalName != null)
+ {
+ if (webXmlRunAs == null)
+ {
+ throw new DeploymentException("run-as-principal: " + principalName
+ + " found in jboss-web.xml but there was no run-as in web.xml");
+ }
+ // See if there are any additional roles for this principal
+ Set extraRoles = getSecurityRoleNamesByPrincipal(principalName);
+ RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, principalName, extraRoles);
+ runAsIdentity.put(servletName, runAs);
+ }
+ else if (webXmlRunAs != null)
+ {
+ RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, null);
+ runAsIdentity.put(servletName, runAs);
+ }
+ }
+
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefDelegate.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.serviceref;
+
+// $Id: ServiceRefDelegate.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.serviceref.ServiceRefElement;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.wsf.spi.util.KernelLocator;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+
+/**
+ * Factory for ServiceRefHandler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 05-May-2004
+ */
+public class ServiceRefDelegate implements ServiceRefHandler
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(ServiceRefDelegate.class);
+
+ private static ServiceRefHandler delegate;
+
+ public ServiceRefDelegate()
+ {
+ if (delegate == null)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ delegate = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
+ }
+
+ if (delegate == null)
+ log.warn("Not registered: " + ServiceRefHandler.BEAN_NAME);
+ }
+
+ public ServiceRefMetaData newServiceRefMetaData()
+ {
+ ServiceRefMetaData sref;
+ if (delegate != null)
+ sref = delegate.newServiceRefMetaData();
+ else
+ sref = new DummyServiceRef();
+ return sref;
+ }
+
+ public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ if (delegate != null)
+ child = delegate.newChild(ref, navigator, namespaceURI, localName, attrs);
+ return child;
+ }
+
+ public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if (delegate != null)
+ delegate.setValue(ref, navigator, namespaceURI, localName, value);
+ }
+
+ public void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader, ServiceRefMetaData sref) throws NamingException
+ {
+ if (delegate != null)
+ delegate.bindServiceRef(encCtx, encName, vfsRoot, loader, sref);
+ }
+
+ public static class DummyServiceRef extends ServiceRefMetaData
+ {
+ private String refName;
+
+ @Override
+ public void setServiceRefName(String name)
+ {
+ this.refName = name;
+ }
+
+ @Override
+ public String getServiceRefName()
+ {
+ return refName;
+ }
+
+ @Override
+ public Object getAnnotatedElement()
+ {
+ return null;
+ }
+
+ @Override
+ public void setAnnotatedElement(Object anElement)
+ {
+ }
+
+ @Override
+ public void importJBossXml(Element element)
+ {
+ }
+
+ @Override
+ public void importStandardXml(Element element)
+ {
+ }
+
+ @Override
+ public boolean isProcessed()
+ {
+ return false;
+ }
+
+ @Override
+ public void setProcessed(boolean flag)
+ {
+ }
+
+ @Override
+ public void merge(ServiceRefMetaData serviceRef)
+ {
+ }
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.serviceref;
+
+// $Id: ServiceRefObjectFactory.java 69712 2008-02-07 22:10:42Z dbhole $
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.serviceref.ServiceRefElement;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+
+/**
+ * A object model factory for <service-ref>
+ *
+ * @author Thomas.Diesler at jboss.com
+ */
+public abstract class ServiceRefObjectFactory implements ObjectModelFactory
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(ServiceRefObjectFactory.class);
+
+
+ public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+ {
+ return new ServiceRefDelegate().newChild(ref, navigator, namespaceURI, localName, attrs);
+ }
+
+ public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ new ServiceRefDelegate().setValue(ref, navigator, namespaceURI, localName, value);
+ }
+
+ public static boolean isJ2EE14Descriptor(Element element)
+ {
+ // Verify J2EE-1.4
+ String nsURI = element.getOwnerDocument().getDocumentElement().getNamespaceURI();
+ boolean isValid = "http://java.sun.com/xml/ns/j2ee".equals(nsURI);
+
+ // Verify JBoss-4.0
+ DocumentType doctype = element.getOwnerDocument().getDoctype();
+ if (isValid == false && doctype != null)
+ {
+ String publicId = doctype.getPublicId();
+ isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD JBOSS 4.2//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Web Application 2.4//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
+ isValid |= "-//JBoss//DTD Application Client 4.2//EN".equals(publicId);
+ }
+
+ if (isValid == false)
+ {
+ String dtstr = (doctype != null ? "[public=" + doctype.getPublicId() + ",system=" + doctype.getSystemId() + "]" : null);
+ log.debug("Skip <service-ref> for: nsURI=" + nsURI + ",doctype=" + dtstr);
+ }
+ return isValid;
+ }
+}
Added: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/AbstractWebDeployer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/AbstractWebDeployer.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/AbstractWebDeployer.java 2008-06-25 18:30:35 UTC (rev 75080)
@@ -0,0 +1,885 @@
+/*
+ * 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.web;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployment.J2eeApplicationMetaData;
+import org.jboss.ejb.Container;
+import org.jboss.ejb.EjbUtil;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.EjbLocalRefMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.MessageDestinationMetaData;
+import org.jboss.metadata.MessageDestinationRefMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
+import org.jboss.wsf.common.URLLoaderAdapter;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.omg.CORBA.ORB;
+
+/** A template pattern class for web deployer integration into JBoss. This class
+should be subclasses by war deployers providers wishing to integrate into
+a JBoss server.
+
+It provides support for mapping the following web-app.xml/jboss-web.xml elements
+into the JBoss server JNDI namespace:
+- env-entry
+- resource-ref
+- resource-env-ref
+- ejb-ref
+- ejb-local-ref
+- security-domain
+
+Subclasses need to implement the {@link #performDeploy(WebApplication, String,
+ WebDescriptorParser) performDeploy()}
+and {@link #performUndeploy(String, WebApplication) performUndeploy()} methods to perform the
+container specific steps and return the web application info required by the
+AbstractWebContainer class.
+
+Integration with the JBossSX security framework is based on the establishment
+of a java:comp/env/security context as described in the
+{@link #linkSecurityDomain(String,Context) linkSecurityDomain } comments.
+The security context provides access to the JBossSX security mgr interface
+implementations for use by subclass request interceptors. A outline of the
+steps for authenticating a user is:
+<code>
+ // Get the username & password from the request context...
+ String username = f(request);
+ String password = f(request);
+ // Get the JBoss security manager from the ENC context
+ InitialContext iniCtx = new InitialContext();
+ SecurityManager securityMgr = (SecurityManager) iniCtx.lookup("java:comp/env/security/securityMgr");
+ SimplePrincipal principal = new SimplePrincipal(username);
+ if( securityMgr.isValid(principal, password) )
+ {
+ // Indicate the user is allowed access to the web content...
+
+ // Propagate the user info to JBoss for any calls into made by the servlet
+ SecurityAssociation.setPrincipal(principal);
+ SecurityAssociation.setCredential(password.toCharArray());
+ }
+ else
+ {
+ // Deny access...
+ }
+</code>
+
+An outline of the steps for authorizing the user is:
+<code>
+ // Get the username & required roles from the request context...
+ String username = f(request);
+ String[] roles = f(request);
+ // Get the JBoss security manager from the ENC context
+ InitialContext iniCtx = new InitialContext();
+ RealmMapping securityMgr = (RealmMapping) iniCtx.lookup("java:comp/env/security/realmMapping");
+ SimplePrincipal principal = new SimplePrincipal(username);
+ Set requiredRoles = new HashSet(Arrays.asList(roles));
+ if( securityMgr.doesUserHaveRole(principal, requiredRoles) )
+ {
+ // Indicate the user has the required roles for the web content...
+ }
+ else
+ {
+ // Deny access...
+ }
+</code>
+
+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. If your adapting a web container that is trying be compatible with
+both 1.1 and 1.2 Java VMs this is something you need to pay special attention
+to. For example, I have seen problems a request interceptor that was handling
+the authentication/authorization callouts in tomcat3.2.1 not having the same
+thread context ClassLoader as was used to dispatch the http service request.
+
+ at see #performDeploy(WebApplication webApp, String warUrl,
+ WebDescriptorParser webAppParser)
+ at see #performUndeploy(String, WebApplication)
+ at see #parseWebAppDescriptors(DeploymentInfo,ClassLoader, WebMetaData)
+ at see #linkSecurityDomain(String, Context)
+ at see org.jboss.security.RealmMapping;
+ at see org.jboss.security.SimplePrincipal;
+ at see org.jboss.security.SecurityAssociation;
+
+ at jmx.mbean
+ name="jboss.web:service=WebServer"
+ extends="org.jboss.deployment.SubDeployerMBean"
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 69712 $
+*/
+public abstract class AbstractWebDeployer
+{
+ public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+ protected Logger log;
+
+ protected MBeanServer server;
+ /** 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;
+
+ public AbstractWebDeployer()
+ {
+ log = Logger.getLogger(getClass());
+ }
+
+ public abstract void init(Object containerConfig) throws Exception;
+
+ public MBeanServer getServer()
+ {
+ return server;
+ }
+ public void setServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ /** 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 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()
+ {
+ 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;
+ }
+
+ /** 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
+ webAppParser.parseWebAppDescriptors(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 di 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(DeploymentInfo di) throws DeploymentException
+ {
+ Thread thread = Thread.currentThread();
+ ClassLoader appClassLoader = thread.getContextClassLoader();
+ WebApplication warInfo = null;
+ try
+ {
+ // Create a classloader for the war to ensure a unique ENC
+ URL[] empty = {};
+ URLClassLoader warLoader = URLClassLoader.newInstance(empty, di.ucl);
+ thread.setContextClassLoader(warLoader);
+ WebDescriptorParser webAppParser = new DescriptorParser(di);
+ String webContext = di.webContext;
+ if (webContext != null && webContext.startsWith("/") == false)
+ webContext = "/" + webContext;
+
+ // Get the war URL
+ URL warURL = di.localUrl != null ? di.localUrl : di.url;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("webContext: " + webContext);
+ log.debug("warURL: " + warURL);
+ log.debug("webAppParser: " + webAppParser);
+ }
+
+ // Get the web.xml and jboss-web.xml descriptor metadata
+ WebMetaData webMetaData = (WebMetaData) di.metaData;
+
+ // inherit the security setup from jboss-app.xml
+ if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
+ {
+ J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData)di.parent.metaData;
+
+ if (webMetaData.getSecurityDomain() == null)
+ webMetaData.setSecurityDomain(appMetaData.getSecurityDomain());
+
+ webMetaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
+ }
+
+ // Register the permissions with the JACC layer
+ String contextID = di.shortName;
+ if( contextID == null )
+ contextID = di.shortName;
+ webMetaData.setJaccContextID(contextID);
+ PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ createPermissions(webMetaData, pc);
+ // Link this to the parent PC
+ DeploymentInfo current = di;
+ while( current.parent != null )
+ current = current.parent;
+ PolicyConfiguration parentPC = (PolicyConfiguration)
+ current.context.get("javax.security.jacc.PolicyConfiguration");
+ if( parentPC != null && parentPC != pc )
+ parentPC.linkConfiguration(pc);
+
+ // Commit the policy configuration
+ pc.commit();
+ // Allow the policy to incorporate the policy configs
+ Policy.getPolicy().refresh();
+
+ warInfo = new WebApplication(webMetaData);
+ warInfo.setDeploymentInfo(di);
+ warInfo.setClassLoader(warLoader);
+ performDeploy(warInfo, warURL.toString(), webAppParser);
+ }
+ catch(DeploymentException e)
+ {
+ di.context.put(ERROR, e);
+ throw e;
+ }
+ catch(Exception e)
+ {
+ DeploymentException ex = new DeploymentException("Error during deploy", e);
+ di.context.put(ERROR, ex);
+ throw ex;
+ }
+ finally
+ {
+ thread.setContextClassLoader(appClassLoader);
+ }
+ return warInfo;
+ }
+
+ /** This method is called by the deploy() 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.
+ @param webAppParser The callback interface the web container should use to
+ setup the web app JNDI environment for use by the web app components. This
+ needs to be invoked after the web app class loader is known, but before
+ and web app components attempt to access the java:comp/env JNDI namespace.
+ */
+ protected abstract void performDeploy(WebApplication webApp, String warUrl,
+ WebDescriptorParser webAppParser) throws Exception;
+
+ /** 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(DeploymentInfo di)
+ throws DeploymentException
+ {
+ URL warURL = di.localUrl != null ? di.localUrl : di.url;
+ String warUrl = warURL.toString();
+ try
+ {
+ WebApplication webApp = (WebApplication) di.context.get(AbstractWebContainer.WEB_APP);
+ performUndeploy(warUrl, webApp);
+ // Unegister the permissions with the JACC layer
+ WebMetaData webMetaData = (WebMetaData) di.metaData;
+ String contextID = webMetaData.getJaccContextID();
+ PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ pc.delete();
+ }
+ catch(DeploymentException e)
+ {
+ throw e;
+ }
+ catch(Exception e)
+ {
+ throw new DeploymentException("Error during deploy", e);
+ }
+ }
+
+ /** Called as part of the undeploy() method template to ask the
+ subclass for perform the web container specific undeployment steps.
+ */
+ protected abstract void performUndeploy(String warUrl, WebApplication webApp)
+ 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 parseWebAppDescriptors(DeploymentInfo di, ClassLoader loader,
+ WebMetaData metaData)
+ throws Exception
+ {
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
+ InitialContext iniCtx = new InitialContext();
+ Context envCtx = null;
+ Thread currentThread = Thread.currentThread();
+ ClassLoader currentLoader = currentThread.getContextClassLoader();
+ 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: Where does this ENC get tidied up?
+ currentThread.setContextClassLoader(loader);
+ metaData.setENCLoader(loader);
+ envCtx = (Context) iniCtx.lookup("java:comp");
+
+ ORB orb = null;
+ try
+ {
+ orb = (ORB) server.getAttribute(Container.ORB_NAME, "ORB");
+ }
+ catch (Throwable t)
+ {
+ log.debug("Unable to retrieve orb" + t.toString());
+ }
+
+ // Bind the orb
+ if (orb != null)
+ {
+ NonSerializableFactory.rebind(envCtx, "ORB", orb);
+ log.debug("Bound java:comp/ORB");
+ }
+
+ // 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");
+ }
+ finally
+ {
+ currentThread.setContextClassLoader(currentLoader);
+ }
+
+ Iterator envEntries = metaData.getEnvironmentEntries();
+ log.debug("addEnvEntries");
+ addEnvEntries(envEntries, envCtx);
+ Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
+ log.debug("linkResourceEnvRefs");
+ linkResourceEnvRefs(resourceEnvRefs, envCtx);
+ Iterator resourceRefs = metaData.getResourceReferences();
+ log.debug("linkResourceRefs");
+ linkResourceRefs(resourceRefs, envCtx);
+ log.debug("linkMessageDestinationRefs");
+ linkMessageDestinationRefs(metaData, envCtx, di);
+ Iterator ejbRefs = metaData.getEjbReferences();
+ log.debug("linkEjbRefs");
+ linkEjbRefs(ejbRefs, envCtx, di);
+ Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
+ log.debug("linkEjbLocalRefs");
+ linkEjbLocalRefs(ejbLocalRefs, envCtx, di);
+ log.debug("linkServiceRefs");
+ linkServiceRefs(metaData, envCtx, di);
+ String securityDomain = metaData.getSecurityDomain();
+ log.debug("linkSecurityDomain");
+ linkSecurityDomain(securityDomain, envCtx);
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
+ }
+
+ private void linkServiceRefs(WebMetaData metaData, Context envCtx, DeploymentInfo di) throws NamingException
+ {
+ UnifiedVirtualFile vfsRoot = new URLLoaderAdapter(di.url);
+ for (ServiceRefMetaData sref : metaData.getServiceReferences().values())
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, di.ucl, sref);
+ }
+ }
+
+ protected void addEnvEntries(Iterator envEntries, Context envCtx)
+ throws ClassNotFoundException, NamingException
+ {
+ while( envEntries.hasNext() )
+ {
+ EnvEntryMetaData entry = (EnvEntryMetaData) envEntries.next();
+ log.debug("Binding env-entry: "+entry.getName()+" of type: " +
+ entry.getType()+" to value:"+entry.getValue());
+ EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+ }
+ }
+
+ protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceEnvRefs.hasNext() )
+ {
+ ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData) resourceEnvRefs.next();
+ String resourceName = ref.getJndiName();
+ String refName = ref.getRefName();
+ 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(Iterator resourceRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceRefs.hasNext() )
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
+ String jndiName = ref.getJndiName();
+ String refName = ref.getRefName();
+ if( ref.getType().equals("java.net.URL") )
+ {
+ try
+ {
+ String resURL = ref.getResURL();
+ if( ref.getResURL() != 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(WebMetaData metaData, Context envCtx, DeploymentInfo di)
+ throws NamingException, DeploymentException
+ {
+ Iterator i = metaData.getMessageDestinationReferences();
+
+ while (i.hasNext())
+ {
+ MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
+
+ String refName = ref.getRefName();
+ String jndiName = ref.getJNDIName();
+ String link = ref.getLink();
+ if (link != null)
+ {
+ if (jndiName == null)
+ {
+ MessageDestinationMetaData messageDestination = EjbUtil.findMessageDestination(server, di, link);
+ if (messageDestination == null)
+ throw new DeploymentException("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 DeploymentException("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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
+ throws NamingException
+ {
+ while( ejbRefs.hasNext() )
+ {
+ EjbRefMetaData ejb = (EjbRefMetaData) ejbRefs.next();
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use ejb-link if it is specified
+ if ( linkName != null )
+ {
+ jndiName = EjbUtil.findEjbLink(server, di, 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(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
+ throws NamingException
+ {
+ while( ejbRefs.hasNext() )
+ {
+ EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use the ejb-link field if it is specified
+ if ( linkName != null )
+ {
+ jndiName = EjbUtil.findLocalEjbLink(server, di, 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);
+ }
+ 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));
+ 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 = AbstractWebContainer.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());
+ }
+ }
+
+ /** Create the JACC permission based on the security constraints obtained
+ * from the web.xml metadata.
+ *
+ * @param metaData
+ * @param pc
+ * @throws PolicyContextException
+ */
+ protected void createPermissions(WebMetaData metaData, PolicyConfiguration pc)
+ throws PolicyContextException
+ {
+ WebPermissionMapping.createPermissions(metaData, pc);
+ }
+
+ /** An inner class that maps the WebDescriptorParser.parseWebAppDescriptors()
+ onto the protected parseWebAppDescriptors() AbstractWebContainer method.
+ */
+ private class DescriptorParser implements WebDescriptorParser
+ {
+ DeploymentInfo di;
+ DescriptorParser(DeploymentInfo di)
+ {
+ this.di = di;
+ }
+ public void parseWebAppDescriptors(ClassLoader loader, WebMetaData metaData)
+ throws Exception
+ {
+ AbstractWebDeployer.this.parseWebAppDescriptors(di, loader, metaData);
+ }
+ public DeploymentInfo getDeploymentInfo()
+ {
+ return di;
+ }
+ }
+}
Property changes on: branches/JBPAPP_4_2_0_GA_CP/server/src/resources/43specific/org/jboss/web/AbstractWebDeployer.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-cvs-commits
mailing list