[jboss-cvs] JBossAS SVN: r94809 - in projects/docs/enterprise/5.0/Examples: admin-config-guide-examples and 48 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 13 23:55:40 EDT 2009
Author: laubai
Date: 2009-10-13 23:55:37 -0400 (Tue, 13 Oct 2009)
New Revision: 94809
Added:
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-cmp2.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jca.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jms.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jmx.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-misc.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-naming.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-security.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-ws.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/lib/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/lib/junit.jar
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/notxfs-ds.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactory.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactoryImpl.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSDirContext.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnection.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionFactory.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionMetaData.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSRequestInfo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/ra.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/log4j.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicSetup.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/SendRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/log4j.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/SendRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/TextMDB.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/SendRecvClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/TextMDB.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/Ex0URLClassLoader.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEa.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEb.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEc.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCtx.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExIAEd.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExLE.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj2.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/log4j.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMap.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMapMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClass.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClassMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclass.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclassMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/TestMySubclass.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMap.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMapMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/jboss-service_1.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocal.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocalHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocal.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocalHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EjbMBeanAdaptor.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/application.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-app.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex4/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex4/JMXBrowser.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ClientInterface.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/JNDIMap.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ServerSecurityInterceptor.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean1.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean3.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBeanRestart.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service2.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service3.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean1.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean2.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean3.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/ExSchedulable.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoSecurityProxy.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/roles.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/users.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex10/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex10/TimedCachePolicy.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/JndiUserAndPass.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStore.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStoreMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClientSetup.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/log4j.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/roles.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStore.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStoreMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/users.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/roles.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/users.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/TstReadOnly.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/http-invoker-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/web.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/Echo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/JSSE_install_check.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/application.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-app.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/example.keystore
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/log4j.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/login-config.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheService.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheServiceMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfig.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfigMBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ContactInfo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalSetUp.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTearDown.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTest.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTestConstants.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Gangster.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Job.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Location.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Organization.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/PhoneNumber.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAhead.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadTest.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jbosscmp-jdbc.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/ex1/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/ex1/ExClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-web.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/jboss-service.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/server.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestCase.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunner.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteAssertionFailedError.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteTestException.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/ChapterExRepository.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/Debug.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/application.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/ExampleClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClient.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClientDII.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/mapping.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/webservices.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/Example.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleHome.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ejb-jar.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/jboss.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/mapping.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/Hello.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloBean.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloPojo.java
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/config.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/servletmeta/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/servletmeta/web.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-ejb-config.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-servlet-config.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/app.policy
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/auth.conf
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/example.keystore
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/jndi.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.properties
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.xml
projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/misc-ex1-bindings.xml
Log:
Added admin-config-guide-examples for QE.
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-cmp2.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-cmp2.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-cmp2.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Build script for the chapter 11 examples -->
+<project name="CMP2 chapter build" default="build-all">
+
+ <property name="src.root" value="src/main/org/jboss/cmp2"/>
+ <property name="chapter.dir" value="${build.dir}/cmp2"/>
+
+ <path id="chapter.path">
+ <pathelement path="${client.path}" />
+ <pathelement location="${lib.dir}/junit.jar" />
+ <pathelement location="${lib.dir}/junitejb.jar" />
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}"/>
+ </target>
+
+ <target name="config" depends="build-ejb.jar">
+ <copy file="${chapter.dir}/cmp2-ex1.jar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+ <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
+ <arg value="org.jboss.cmp2.crimeportal.CrimePortalSetUp"/>
+ <sysproperty key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
+ <sysproperty key="java.naming.provider.url" value="jnp://localhost:1099"/>
+ <sysproperty key="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
+ <classpath refid="chapter.path"/>
+ </java>
+ </target>
+
+ <target name="build-all">
+ <antcall target="build-ejb.jar"/>
+ </target>
+
+ <target name="build-ejb.jar" depends="prepare">
+ <jar jarfile="${chapter.dir}/cmp2-ex1.jar">
+ <metainf dir="${src.root}">
+ <include name="ejb-jar.xml" />
+ <include name="jboss.xml" />
+ <include name="jbosscmp-jdbc.xml" />
+ </metainf>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/cmp2/crimeportal/*" />
+ <include name="org/jboss/test/util/ejb/*" />
+ </fileset>
+ <zipfileset src="${lib.dir}/junit.jar" includes="junit/**/*.*"/>
+ </jar>
+ </target>
+
+ <target name="run-examplereadahead">
+ <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
+ <arg value="org.jboss.cmp2.crimeportal.ReadAheadTest"/>
+ <classpath refid="chapter.path"/>
+ </java>
+ </target>
+ <target name="run-exampletest">
+ <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
+ <arg value="org.jboss.cmp2.crimeportal.CrimePortalTest"/>
+ <classpath refid="chapter.path"/>
+ </java>
+ </target>
+ <target name="run-examplereadahead-gui">
+ <java fork="yes" classname="junit.swingui.TestRunner" taskname="junit" failonerror="true">
+ <arg value="org.jboss.cmp2.crimeportal.ReadAheadTest"/>
+ <classpath refid="chapter.path"/>
+ </java>
+ </target>
+ <target name="run-exampletest-gui">
+ <java fork="yes" classname="junit.swingui.TestRunner" taskname="junit" failonerror="true">
+ <arg value="org.jboss.cmp2.crimeportal.CrimePortalTest"/>
+ <classpath refid="chapter.path"/>
+ </java>
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jca.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jca.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jca.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,54 @@
+<project name="JCA chapter examples" default="build-all">
+
+ <property name="src.root" value="src/main/org/jboss/book/jca" />
+ <property name="chapter.dir" value="${build.dir}/jca" />
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}" />
+ </target>
+
+ <target name="build-all">
+ <antcall target="jca-ex1-rar" />
+ <antcall target="jca-ex1-jar" />
+ </target>
+
+ <target name="config">
+ <copy file="${chapter.dir}/jca-ex1.rar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <copy file="${src.root}/ex1/notxfs-ds.xml" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ </target>
+
+ <target name="jca-ex1-rar" depends="prepare">
+ <jar jarfile="${chapter.dir}/ra.jar">
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jca/ex1/ra/**" />
+ </jar>
+ <jar jarfile="${chapter.dir}/jca-ex1.rar">
+ <metainf dir="${src.root}/ex1/ra" includes="ra.xml"/>
+ <fileset dir="${chapter.dir}"
+ includes="ra.jar" />
+ </jar>
+ </target>
+ <target name="jca-ex1-jar" depends="prepare">
+ <jar jarfile="${chapter.dir}/jca-ex1.jar">
+ <metainf dir="${src.root}/ex1" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jca/ex1/*"
+ excludes="org/jboss/book/jca/ex1/ExClient.class" />
+ </jar>
+ </target>
+
+ <!-- Examples -->
+
+ <target name="run-example1" depends="jca-ex1-jar">
+ <copy file="${chapter.dir}/jca-ex1.jar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <echo message="Waiting for deploy..." />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jca.ex1.ExClient"
+ classpath="${client.path}" fork="true" >
+ </java>
+ </target>
+
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jms.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jms.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jms.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,98 @@
+<project name="JMS Chapter Examples" default="build-all">
+ <property name="src.root" value="src/main/org/jboss/book/jms" />
+ <property name="chapter.dir" value="${build.dir}/jms" />
+ <property name="chapter.ex" value="jms-ex${ex}" />
+
+ <path id="chapter.path">
+ <pathelement location="src/main" />
+ <pathelement location="output/classes" />
+ <pathelement path="${client.path}" />
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}" />
+ </target>
+
+ <target name="jms-ex2-jar" depends="prepare">
+ <jar jarfile="${chapter.dir}/jms-ex2.jar">
+ <metainf dir="${src.root}/ex2" includes="*.xml"/>
+ <fileset dir="${build.classes.dir}" includes="org/jboss/book/jms/ex2/**"/>
+ </jar>
+ </target>
+ <target name="jms-ex3-jar" depends="prepare">
+ <jar jarfile="${chapter.dir}/jms-ex3.jar">
+ <metainf dir="${src.root}/ex3" includes="*.xml"/>
+ <fileset dir="${build.classes.dir}" includes="org/jboss/book/jms/ex3/**"/>
+ </jar>
+ </target>
+
+ <target name="build-all">
+ <antcall target="jms-ex2-jar" />
+ </target>
+
+ <target name="run-example1p2p">
+ <java classname="org.jboss.book.jms.ex1.SendRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+
+ <target name="run-example1p2pex">
+ <java classname="org.jboss.book.jms.ex1.SendRecvExListenerClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+
+ <target name="run-example1p2psecure">
+ <java classname="org.jboss.book.jms.ex1.SecureSendRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+ <target name="run-example1ps">
+ <java classname="org.jboss.book.jms.ex1.TopicSendRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+ <target name="run-example1ps2">
+ <java classname="org.jboss.book.jms.ex1.TopicSendClient"
+ classpathref="chapter.path" fork="true" />
+
+ <java classname="org.jboss.book.jms.ex1.TopicRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+
+ <target name="run-example1psdt">
+ <java classname="org.jboss.book.jms.ex1.DurableTopicSetup"
+ classpathref="chapter.path" fork="true" />
+ <java classname="org.jboss.book.jms.ex1.TopicSendClient"
+ classpathref="chapter.path" fork="true" />
+ <java classname="org.jboss.book.jms.ex1.DurableTopicRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+ <target name="run-example1dt">
+ <java classname="org.jboss.book.jms.ex1.DurableTopicClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+
+ <target name="run-example2" depends="jms-ex2-jar">
+ <copy file="${chapter.dir}/jms-ex2.jar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <echo message="Waiting 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jms.ex2.SendRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+ <target name="run-example2np">
+ <copy file="${chapter.dir}/jms-ex2.jar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <echo message="Waiting 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jms.ex2.SendRecvClientNP"
+ classpathref="chapter.path" fork="true">
+ </java>
+ </target>
+ <target name="run-example3" depends="jms-ex3-jar">
+ <copy file="${chapter.dir}/jms-ex3.jar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <echo message="Waiting 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jms.ex3.SendRecvClient"
+ classpathref="chapter.path" fork="true" />
+ </target>
+
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jmx.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jmx.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-jmx.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,238 @@
+<!-- Build script for the chapter 2 examples -->
+<project name="Chapter 2 build" default="build-all">
+
+ <property name="src.root" value="src/main/org/jboss/book/jmx" />
+ <property name="chapter.dir" value="${build.dir}/jmx" />
+ <property name="chapter.ex" value="jmx-ex${ex}" />
+
+ <path id="chapter.path">
+ <pathelement location="src/main"/>
+ <pathelement path="${client.path}" />
+ <pathelement location="${jboss.dist}/lib/jboss-jmx.jar"/>
+ <pathelement location="${jboss.dist}/client/jbossall-client.jar" />
+ <pathelement location="${jboss.dist}/lib/dom4j.jar" />
+ </path>
+
+ <target name="build-all">
+ <antcall target="jmx-ex0-jars" />
+ <antcall target="jmx-ex1-sar" />
+ <antcall target="jmx-ex1xmbean1-sar" />
+ <antcall target="jmx-ex1xmbean2-sar" />
+ <antcall target="jmx-ex1xmbean3-sar" />
+ <antcall target="jmx-ex2-sar" />
+ <antcall target="jmx-ex3-ear" />
+ <antcall target="rmic" />
+ </target>
+
+ <target name="rmic">
+ <rmic base="${build.classes.dir}" classpathref="chapter.path"
+ includes="org/jboss/book/jmx/xmbean/TestXMBean1$*.class"/>
+ </target>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}" />
+ </target>
+
+ <target name="config">
+ </target>
+
+ <target name="jmx-ex0-jars" depends="prepare">
+ <jar jarfile="${chapter.dir}/j0.jar">
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/jmx/ex0/ExCtx.class" />
+ <include name="org/jboss/book/jmx/ex0/ExObj*.class" />
+ </fileset>
+ </jar>
+ <jar jarfile="${chapter.dir}/j1.jar">
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/jmx/ex0/ExCtx.class" />
+ <include name="org/jboss/book/jmx/ex0/ExObj*.class" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="jmx-ex1-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/jmx-ex1.sar">
+ <metainf dir="${src.root}/ex1" includes="*.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/ex1/**"
+ />
+ </jar>
+ </target>
+
+ <!-- The JNDIMap XMBean version 1 -->
+ <target name="jmx-ex1xmbean1-sar" depends="prepare">
+ <zip destfile="${chapter.dir}/jmx-ex1xmbean1.sar">
+ <zipfileset dir="${src.root}/xmbean" prefix="META-INF">
+ <include name="jboss-service.xml"/>
+ </zipfileset>
+ <zipfileset dir="${src.root}/xmbean" fullpath="META-INF/jndimap-xmbean.xml">
+ <include name="jndimap-xmbean1.xml"/>
+ </zipfileset>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/xmbean/**"
+ />
+ </zip>
+ </target>
+
+ <!-- The JNDIMap XMBean version 2 -->
+ <target name="jmx-ex1xmbean2-sar" depends="prepare">
+ <zip destfile="${chapter.dir}/jmx-ex1xmbean2.sar">
+ <zipfileset dir="${src.root}/xmbean" fullpath="META-INF/jboss-service.xml">
+ <include name="jboss-service2.xml"/>
+ </zipfileset>
+ <zipfileset dir="${src.root}/xmbean" fullpath="META-INF/jndimap-xmbean.xml">
+ <include name="jndimap-xmbean2.xml"/>
+ </zipfileset>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/xmbean/**"
+ />
+ </zip>
+ </target>
+
+ <!-- The JNDIMap XMBean version 3 -->
+ <target name="jmx-ex1xmbean3-sar" depends="prepare">
+ <zip destfile="${chapter.dir}/jmx-ex1xmbean3.sar">
+ <zipfileset dir="${src.root}/xmbean"
+ fullpath="META-INF/jboss-service.xml">
+ <include name="jboss-service3.xml"/>
+ </zipfileset>
+ <zipfileset dir="${src.root}/xmbean" prefix="META-INF">
+ <include name="jndimap-xmbean3.xml"/>
+ </zipfileset>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/xmbean/**"
+ />
+ </zip>
+ </target>
+
+ <target name="jmx-ex2-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/jmx-ex2.sar">
+ <metainf dir="${src.root}/ex2" includes="*.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/ex2/**"
+ />
+ </jar>
+ </target>
+
+ <target name="jmx-ex3-ear" depends="prepare">
+ <jar jarfile="${chapter.dir}/jmx-ex3.sar">
+ <metainf dir="${src.root}/ex3" includes="jboss-service.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/ex3/EjbMBeanAdaptor.class"
+ />
+ </jar>
+ <jar jarfile="${chapter.dir}/jmx-ex3.jar">
+ <metainf dir="${src.root}/ex3" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/jmx/ex3/Echo*.class"
+ />
+ </jar>
+ <ear earfile="${chapter.dir}/jmx-ex3.ear"
+ appxml="${src.root}/ex3/application.xml">
+ <metainf dir="${src.root}/ex3">
+ <include name="jboss-app.xml" />
+ </metainf>
+ <fileset dir="${chapter.dir}">
+ <include name="jmx-ex3.jar" />
+ <include name="jmx-ex3.sar" />
+ </fileset>
+ </ear>
+ </target>
+
+ <!-- The targets for running the examples -->
+ <target name="run-example0b" depends="jmx-ex0-jars">
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExCtx.class" />
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExObj.class" />
+ <java classname="org.jboss.book.jmx.ex0.ExCCEb" fork="true">
+ <classpath refid="chapter.path" />
+ <sysproperty key="chapter.dir" value="${chapter.dir}"/>
+ <sysproperty key="chapter.ex" value="${chapter.ex}" />
+ </java>
+ </target>
+
+ <target name="run-example0c" depends="jmx-ex0-jars">
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExCtx.class" />
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExObj.class" />
+ <java classname="org.jboss.book.jmx.ex0.ExCCEc" fork="true">
+ <classpath refid="chapter.path" />
+ <sysproperty key="chapter.dir" value="${chapter.dir}"/>
+ <sysproperty key="chapter.ex" value="${chapter.ex}" />
+ </java>
+ </target>
+
+ <target name="run-example0d" depends="jmx-ex0-jars">
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExCtx.class" />
+ <java classname="org.jboss.book.jmx.ex0.ExIAEd" fork="true">
+ <classpath refid="chapter.path" />
+ <sysproperty key="chapter.dir" value="${chapter.dir}"/>
+ <sysproperty key="chapter.ex" value="${chapter.ex}" />
+ </java>
+ </target>
+
+ <target name="run-example0e" depends="jmx-ex0-jars">
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExCtx.class" />
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExObj.class" />
+ <delete file="${build.classes.dir}/org/jboss/book/jmx/ex0/ExObj2.class" />
+ <java classname="org.jboss.book.jmx.ex0.ExLE" fork="true">
+ <classpath refid="chapter.path" />
+ <sysproperty key="chapter.dir" value="${chapter.dir}"/>
+ <sysproperty key="chapter.ex" value="${chapter.ex}" />
+ </java>
+ </target>
+
+ <target name="run-example1">
+ <java classname="org.jboss.book.jmx.ex1.TestMySubclass" fork="true">
+ <classpath refid="chapter.path" />
+ <classpath>
+
+ </classpath>
+ </java>
+ </target>
+ <target name="run-examplexmbean1" depends="rmic,jmx-ex1xmbean1-sar">
+ <copy file="${chapter.dir}/jmx-ex1xmbean1.sar" todir="${jboss.deploy.dir}" />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jmx.xmbean.TestXMBean1" fork="true">
+ <classpath refid="chapter.path" />
+ </java>
+ </target>
+ <target name="run-examplexmbean2" depends="rmic,jmx-ex1xmbean2-sar">
+ <delete file="${jboss.deploy.dir}/jmx-ex1xmbean1.sar" />
+ <copy file="${chapter.dir}/jmx-ex1xmbean2.sar" todir="${jboss.deploy.dir}" />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jmx.xmbean.TestXMBean1" fork="true">
+ <classpath refid="chapter.path" />
+ </java>
+ </target>
+ <target name="run-examplexmbean2a" depends="rmic,jmx-ex1xmbean2-sar">
+ <copy file="${chapter.dir}/jmx-ex1xmbean2.sar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jmx.xmbean.TestXMBeanRestart" fork="true">
+ <classpath refid="chapter.path" />
+ </java>
+ </target>
+ <target name="run-examplexmbean3" depends="rmic,jmx-ex1xmbean3-sar">
+ <copy file="${chapter.dir}/jmx-ex1xmbean3.sar" todir="${jboss.deploy.dir}" />
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.jmx.xmbean.TestXMBean3" fork="true">
+ <classpath refid="chapter.path" />
+ </java>
+ </target>
+
+ <target name="run-example3" depends="jmx-ex3-ear">
+ <copy file="${chapter.dir}/jmx-ex3.ear" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ </target>
+
+ <target name="run-example4">
+ <property name="cp" refid="chapter.path" />
+ <java classname="org.jboss.book.jmx.ex4.JMXBrowser" fork="true">
+ <classpath refid="chapter.path" />
+ <classpath>
+ <pathelement location="${jboss.dist}/client/jbossall-client.jar" />
+ <pathelement location="${jboss.dist}/lib/dom4j.jar" />
+ </classpath>
+ </java>
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-misc.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-misc.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-misc.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,85 @@
+<project name="misc examples build" default="build-all">
+ <property name="src.root" value="src/main/org/jboss/book/misc" />
+ <property name="chapter.dir" value="${build.dir}/misc"/>
+
+ <path id="chapter.path">
+ <pathelement location="src/main" />
+ <pathelement location="output/classes" />
+ <pathelement path="${client.path}" />
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}"/>
+ </target>
+
+ <target name="build-all">
+ <antcall target="misc-ex2-sar" />
+ </target>
+
+ <target name="config">
+
+ </target>
+
+ <target name="misc-ex2-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/misc-ex2.sar">
+ <metainf dir="${src.root}/ex2" includes="jboss-service.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/misc/ex2/*" />
+ </fileset>
+ </jar>
+ </target>
+ <!-- Examples -->
+
+ <target name="run-example1">
+ <!-- Create a copy of jboss.deploy.conf as jboss0 -->
+ <echo message="Preparing jboss0 configuration fileset"/>
+ <mkdir dir="${jboss.dist}/server/jboss0"/>
+ <copy todir="${jboss.dist}/server/jboss0">
+ <fileset dir="${jboss.dist}/server/${jboss.deploy.conf}">
+ <exclude name="data/**"/>
+ <exclude name="deploy/chap*"/>
+ <exclude name="log/**"/>
+ <exclude name="tmp/**"/>
+ </fileset>
+ </copy>
+
+ <echo message="Copying misc-ex1-bindings.xml File"/>
+ <copy todir="${jboss.dist}/server/"
+ file="${src.resources}/misc-ex1-bindings.xml"/>
+
+ <echo message="Update jboss-service.xml to use misc-ex1-bindings.xml"/>
+ <replace file="${jboss.dist}/server/jboss0/conf/jboss-service.xml">
+ <replacetoken><![CDATA[<!-- @TESTSUITE_CLUSTER_CONFIG@ -->]]></replacetoken>
+ <replacevalue><![CDATA[
+ <mbean code="org.jboss.services.binding.ServiceBindingManager"
+ name="jboss.system:service=ServiceBindingManager">
+ <attribute name="ServerName">${jboss.server.name}</attribute>
+ <attribute name="StoreURL">${jboss.server.base.dir}/misc-ex1-bindings.xml</attribute>
+ <attribute name="StoreFactoryClassName">
+ org.jboss.services.binding.XMLServicesStoreFactory
+ </attribute>
+ </mbean>
+ ]]></replacevalue>
+ </replace>
+
+ <echo message="Preparing jboss1 configuration fileset"/>
+ <mkdir dir="${jboss.dist}/server/jboss1"/>
+ <copy todir="${jboss.dist}/server/jboss1">
+ <fileset dir="${jboss.dist}/server/jboss0">
+ <exclude name="data/**"/>
+ <exclude name="log/**"/>
+ <exclude name="tmp/**"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="run-example2" depends="misc-ex2-sar">
+ <copy file="${chapter.dir}/misc-ex2.sar" todir="${jboss.deploy.dir}"
+ overwrite="true" />
+ </target>
+
+ <target name="run-examplebind">
+ <java classname="org.jboss.book.misc.jndibind.Lookup"
+ classpathref="chapter.path" fork="true" />
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-naming.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-naming.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-naming.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,45 @@
+<!-- Build script for the chapter 3 examples -->
+<project name="Chapter 3 build" default="build-all">
+ <property name="src.root" value="src/main/org/jboss/naming" />
+ <property name="chapter.dir" value="${build.dir}/naming" />
+
+ <target name="build-all" depends="prepare" />
+
+ <target name="prepare">
+ </target>
+
+ <target name="config">
+ <echo message="Preparing naming configuration fileset" />
+ <mkdir dir="${jboss.dist}/server/naming" />
+ <copy todir="${jboss.dist}/server/naming">
+ <fileset dir="${jboss.dist}/server/default">
+ <exclude name="data/**"/>
+ <exclude name="log/**"/>
+ <exclude name="tmp/**"/>
+ </fileset>
+ </copy>
+ <copy file="${src.resources}/example.keystore" overwrite="true"
+ todir="${jboss.dist}/server/naming/conf" />
+<!-- already has keystore
+ <copy file="${src.root}/jboss-service.xml" overwrite="true"
+ todir="${jboss.dist}/server/naming/conf" />
+-->
+ <copy file="${src.root}/server.xml" overwrite="true"
+ tofile="${jboss.dist}/server/naming/deploy/jboss-web.deployer/server.xml" />
+ <copy file="${src.root}/invoker-service.xml" overwrite="true"
+ tofile="${jboss.dist}/server/naming/deploy/http-invoker.sar/META-INF/jboss-service.xml" />
+ <copy file="${src.root}/invoker-web.xml" overwrite="true"
+ tofile="${jboss.dist}/server/naming/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml" />
+ </target>
+
+ <target name="run-example1">
+ <java classname="org.jboss.naming.ex1.ExClient" fork="true">
+ <classpath>
+ <pathelement path="${client.path}" />
+ <pathelement location="${jboss.dist}/lib/jboss-jmx.jar"/>
+ </classpath>
+ <jvmarg value="-Djavax.net.ssl.trustStore=${jboss.dist}/server/naming/conf/example.keystore" />
+ <jvmarg value="-Dorg.jboss.security.ignoreHttpsHost=true" />
+ </java>
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-security.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-security.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-security.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,278 @@
+<project name="security chapter examples" default="build-all">
+ <property name="src.root" value="src/main/org/jboss/book/security"/>
+ <property name="chapter.dir" value="${build.dir}/security"/>
+
+ <path id="chapter.path">
+ <pathelement location="src/main"/>
+ <pathelement path="${client.path}"/>
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}"/>
+ </target>
+
+ <target name="config">
+ <!-- Setup a custom config for the ex3a examples -->
+ <echo message="Preparing security-ex3a configuration fileset"/>
+ <copy todir="${jboss.dist}/server/security-ex3a">
+ <fileset dir="${jboss.dist}/server/all">
+ <exclude name="db/**"/>
+ <exclude name="log/**"/>
+ <exclude name="tmp/**"/>
+ </fileset>
+ </copy>
+ <!-- Setup a custom config for the ex3b examples -->
+ <echo message="Preparing security-ex3b configuration fileset"/>
+ <copy todir="${jboss.dist}/server/security-ex3b">
+ <fileset dir="${jboss.dist}/server/all">
+ <exclude name="db/**"/>
+ <exclude name="log/**"/>
+ <exclude name="tmp/**"/>
+ </fileset>
+ </copy>
+ <copy file="${src.root}/ex3b/http-invoker-service.xml" overwrite="true" tofile="${jboss.dist}/server/security-ex3b/deploy/http-invoker.sar/META-INF/jboss-service.xml"/>
+ <copy file="${src.root}/ex3b/web.xml" overwrite="true" todir="${jboss.dist}/server/security-ex3b/deploy/http-invoker.sar/invoker.war/WEB-INF"/>
+ <replace file="${jboss.dist}/server/security-ex3b/deploy/jbossweb.sar/META-INF/jboss-service.xml">
+ <replacetoken><![CDATA[<mbean code="org.jboss.jetty.JettyService" name="jboss.web:service=JBossWeb">]]></replacetoken>
+ <replacevalue><![CDATA[<mbean code="org.jboss.jetty.JettyService" name="jboss.web:service=JBossWeb">
+ <depends>jboss:service=DefaultPartition</depends>]]></replacevalue>
+ </replace>
+ </target>
+
+ <target name="build-all">
+ <antcall target="security-ex1-jar"/>
+ <antcall target="security-ex2-jar"/>
+ <antcall target="security-ex3-jar"/>
+ <antcall target="security-ex3a-jar"/>
+ <antcall target="security-ex3b-jar"/>
+ <antcall target="security-ex4-jar"/>
+ </target>
+
+ <target name="security-ex1-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex1.sar">
+ <metainf dir="${src.root}/ex1" includes="jboss-service.xml"/>
+ <metainf dir="${src.root}" includes="login-config.xml"/>
+ <fileset dir="${build.classes.dir}" includes="org/jboss/book/security/service/*"/>
+ </jar>
+ </target>
+
+ <target name="security-ex1-jar" depends="security-ex1-sar">
+ <jar jarfile="${chapter.dir}/security-ex1.jar">
+ <metainf dir="${src.root}/ex1" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}" includes="org/jboss/book/security/ex1/*" excludes="org/jboss/book/security/ex1/ExClient.class"/>
+ <fileset dir="${src.root}/ex1" includes="*.properties"/>
+ <fileset dir="${chapter.dir}" includes="security-ex1.sar"/>
+ </jar>
+ </target>
+
+ <target name="security-ex2-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex2.sar">
+ <metainf dir="${src.root}/ex2" includes="jboss-service.xml"/>
+ <metainf dir="${src.root}" includes="login-config.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/service/*"/>
+ <include name="org/jboss/book/security/ex2/service/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="security-ex2-jar" depends="security-ex2-sar">
+ <jar jarfile="${chapter.dir}/security-ex2.jar">
+ <metainf dir="${src.root}/ex2" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/ex2/*"/>
+ <exclude name="org/jboss/book/security/ex1/ExClient.class"/>
+ </fileset>
+ <fileset dir="${chapter.dir}" includes="security-ex2.sar"/>
+ </jar>
+ </target>
+
+ <target name="security-ex3-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex3.sar">
+ <metainf dir="${src.root}/ex3" includes="jboss-service.xml"/>
+ <metainf dir="${src.root}" includes="login-config.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/service/*"/>
+ <include name="org/jboss/book/security/ex3/service/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="security-ex3-jar" depends="security-ex3-sar">
+ <jar jarfile="${chapter.dir}/security-ex3.jar">
+ <metainf dir="${src.root}/ex3" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}" includes="org/jboss/book/security/ex3/*" excludes="org/jboss/book/security/ex3/ExClient*"/>
+ <fileset dir="${src.root}/ex3" includes="*.properties"/>
+ <fileset dir="${chapter.dir}" includes="security-ex3.sar"/>
+ </jar>
+ </target>
+
+ <target name="security-ex3a-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex3a.sar">
+ <metainf dir="${src.root}/ex3a" includes="jboss-service.xml"/>
+ <metainf dir="${src.root}" includes="login-config.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/service/*"/>
+ <include name="org/jboss/book/security/ex3/service/*"/>
+ <include name="org/jboss/book/security/ex3a/service/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="security-ex3a-jar" depends="security-ex3a-sar">
+ <jar jarfile="${chapter.dir}/security-ex3a.jar">
+ <metainf dir="${src.root}/ex3a" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/security/ex3a/*" excludes="org/jboss/book/security/ex3a/ExClient*"/>
+ <fileset dir="${src.root}/ex3a" includes="*.properties"/>
+ <fileset dir="${chapter.dir}" includes="security-ex3a.sar"/>
+ </jar>
+ </target>
+
+ <target name="security-ex3b-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex3b.sar">
+ <metainf dir="${src.root}/ex3b" includes="jboss-service.xml"/>
+ <metainf dir="${src.root}" includes="login-config.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/service/*"/>
+ <include name="org/jboss/book/security/ex3/service/*"/>
+ <include name="org/jboss/book/security/ex3a/service/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="security-ex3b-jar" depends="security-ex3b-sar">
+ <jar jarfile="${chapter.dir}/security-ex3b.jar">
+ <metainf dir="${src.root}/ex3a" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}"
+ includes="org/jboss/book/security/ex3a/*" excludes="org/jboss/book/security/ex3a/ExClient*"/>
+ <fileset dir="${src.root}/ex3a" includes="*.properties"/>
+ <fileset dir="${chapter.dir}" includes="security-ex3b.sar"/>
+ </jar>
+ </target>
+
+ <target name="security-ex4-sar" depends="prepare">
+ <jar jarfile="${chapter.dir}/security-ex4.sar">
+ <metainf dir="${src.root}/ex4" includes="jboss-service.xml"/>
+ <fileset dir="${src.root}">
+ <include name="example.keystore"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="security-ex4-jar" depends="security-ex4-sar">
+ <jar jarfile="${chapter.dir}/security-ex4.jar">
+ <metainf dir="${src.root}/ex4" includes="ejb-jar.xml,jboss.xml"/>
+ <fileset dir="${build.classes.dir}">
+ <include name="org/jboss/book/security/ex4/*"/>
+ <exclude name="org/jboss/book/security/ex4/ExClient.class"/>
+ <exclude name="org/jboss/book/security/ex4/JSSE_install_check.class"/>
+ </fileset>
+ <fileset dir="${chapter.dir}" includes="security-ex4.sar"/>
+ </jar>
+ </target>
+
+ <!-- Examples -->
+
+ <target name="run-example1" depends="security-ex1-jar">
+ <copy file="${chapter.dir}/security-ex1.jar"
+ todir="${jboss.deploy.dir}" overwrite="true" />
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5" />
+ <java classname="org.jboss.book.security.ex1.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager" />
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ </java>
+ </target>
+
+
+ <target name="run-example2" depends="security-ex2-jar">
+ <copy file="${chapter.dir}/security-ex2.jar" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <echo message="Waiting for 5 seconds for deploy..."/>
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.security.ex2.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djava.security.auth.login.config=${src.resources}/auth.conf"/>
+ <arg value="jduke"/>
+ <arg value="theduke"/>
+ </java>
+ </target>
+ <target name="run-example3" depends="security-ex3-jar">
+ <copy file="${chapter.dir}/security-ex3.jar" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <echo message="Waiting for 5 seconds for deploy..."/>
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.security.ex3.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djava.security.auth.login.config=${src.resources}/auth.conf"/>
+ <arg value="jduke"/>
+ <arg value="theduke"/>
+ </java>
+ </target>
+ <target name="run-example3a" depends="security-ex3a-jar">
+ <echo message="The ${chapter.dir}/security-ex3a.jar must have been deployed to the cluster"/>
+ <java classname="org.jboss.book.security.ex3a.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djava.security.auth.login.config=${src.resources}/auth.conf"/>
+ <arg value="jduke"/>
+ <arg value="theduke"/>
+ </java>
+ </target>
+ <target name="run-example3b" depends="security-ex3b-jar">
+ <echo message="The ${chapter.dir}/security-ex3b.jar must have been deployed to the cluster and -c security-ex3b"/>
+ <java classname="org.jboss.book.security.ex3b.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djava.security.auth.login.config=${src.resources}/auth.conf"/>
+ <arg value="jduke"/>
+ <arg value="theduke"/>
+ </java>
+ </target>
+ <target name="run-example3bro">
+ <echo message="The ${chapter.dir}/security-ex3b.jar must have been deployed to the cluster and -c security-ex3b"/>
+ <java classname="org.jboss.book.security.ex3b.TstReadOnly"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djava.security.auth.login.config=${src.resources}/auth.conf"/>
+ </java>
+ </target>
+ <target name="run-example4a" depends="security-ex4-jar">
+ <echo message="Testing JSSE availablility"/>
+ <java classname="org.jboss.book.security.ex4.JSSE_install_check"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djavax.net.debug=all"/>
+ </java>
+ </target>
+ <target name="run-example4b" depends="security-ex4-jar">
+ <copy file="${chapter.dir}/security-ex4.jar" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <echo message="Waiting for 15 seconds for deploy..."/>
+ <sleep seconds="15"/>
+ <java classname="org.jboss.book.security.ex4.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djavax.net.debug=trustmanager"/>
+ </java>
+ </target>
+ <target name="run-example4" depends="security-ex4-jar">
+ <copy file="${chapter.dir}/security-ex4.jar" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <echo message="Waiting for 5 seconds for deploy..."/>
+ <sleep seconds="5"/>
+ <java classname="org.jboss.book.security.ex4.ExClient"
+ classpathref="chapter.path" fork="true">
+ <jvmarg value="-Djava.security.manager"/>
+ <jvmarg value="-Djava.security.policy=${src.resources}/app.policy"/>
+ <jvmarg value="-Djavax.net.ssl.trustStore=${src.root}/example.keystore"/>
+ </java>
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-ws.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-ws.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build-ws.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,225 @@
+<?xml version="1.0"?>
+
+<!-- Build script for the chapter 12 examples -->
+<project name="Chapter 12 build" default="build-all">
+ <property name="chapter.dir" value="${build.dir}/ws" />
+
+ <path id="client.path">
+ <pathelement location="${src.resources}" />
+ <!-- <pathelement location="${lib.dir}/log4j.jar" />-->
+
+ <fileset dir="${jboss.dist}/client">
+ <include name="**/*.jar" />
+ <!--<exclude name="log4j.jar" />-->
+ </fileset>
+
+ <pathelement location="${jboss.dist}/server/default/lib/cglib.jar" />
+ <pathelement location="${lib.dir}/asm.jar" />
+ <pathelement location="${build.classes.dir}" />
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${chapter.dir}" />
+ <mkdir dir="${build.src.dir}/wsdl" />
+ </target>
+
+ <target name="config">
+ </target>
+
+ <target name="compile-src" depends="config">
+ </target>
+
+ <target name="build-all">
+ <antcall target="chap12-jars" />
+ </target>
+
+ <target name="wstools-ejb">
+ <taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools">
+ <classpath refid="client.path" />
+ </taskdef>
+
+ <mkdir dir="${chapter.dir}/ejb" />
+
+ <wstools dest="${chapter.dir}/ejb"
+ config="${src.dir}/org/jboss/ws/wstools-ejb-config.xml"/>
+ </target>
+
+ <target name="wstools-servlet">
+ <taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools">
+ <classpath refid="client.path" />
+ </taskdef>
+
+ <mkdir dir="${chapter.dir}/servlet" />
+
+ <wstools dest="${chapter.dir}/servlet"
+ config="${src.dir}/org/jboss/ws/wstools-servlet-config.xml"/>
+ </target>
+
+ <target name="chap12-jars" depends="prepare,wstools-ejb">
+ <jar destfile="${chapter.dir}/hello-ejb.jar"
+ basedir="${build.classes.dir}">
+ <metainf dir="${src.dir}/org/jboss/ws/ejbmeta">
+ <include name="ejb-jar.xml" />
+ </metainf>
+
+ <metainf dir="${chapter.dir}/ejb">
+ <include name="jaxrpc-mapping.xml" />
+ <include name="webservices.xml" />
+ <include name="wsdl/HelloService.wsdl" />
+ </metainf>
+
+ <include name="org/jboss/ws/hello/**" />
+ </jar>
+ </target>
+
+ <target name="chap12-war" depends="prepare,wstools-servlet">
+ <property name="meta" value="${src.dir}/org/jboss/ws/servletmeta" />
+
+ <war destfile="${chapter.dir}/hello-servlet.war" webxml="${meta}/web.xml">
+ <webinf dir="${chapter.dir}/servlet">
+ <include name="jaxrpc-mapping.xml" />
+ <include name="webservices.xml" />
+ <include name="wsdl/HelloService.wsdl" />
+ </webinf>
+
+ <classes dir="${build.classes.dir}">
+ <include name="org/jboss/ws/hello/*.class" />
+ </classes>
+ </war>
+ </target>
+
+ <target name="ch12-ex.jar" depends="prepare">
+ <jar destfile="${chapter.dir}/ch12-ex.jar"
+ basedir="${build.classes.dir}">
+
+ <metainf dir="${src.dir}/org/jboss/ws/example">
+ <include name="ejb-jar.xml" />
+ <include name="jboss.xml" />
+ <include name="mapping.xml" />
+ </metainf>
+
+ <metainf dir="${src.dir}/org/jboss/ws/hello/">
+ <include name="wsdl/HelloService.wsdl" />
+ </metainf>
+
+ <include name="org/jboss/ws/example/*.class" />
+ <include name="org/jboss/ws/hello/Hello.class" />
+ </jar>
+ </target>
+
+
+
+ <target name="run-example1" depends="chap12-war">
+ <copy file="${chapter.dir}/hello-servlet.war"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+
+ <java dir="${build.classes.dir}" fork="yes" failOnError="true"
+ className="org.jboss.ws.client.HelloClient">
+
+ <jvmarg value="-Djava.endorsed.dirs=${jboss.dist}/lib/endorsed" />
+ <arg value="http://localhost:8080/hello-servlet/Hello?wsdl" />
+ <arg value="JBoss user" />
+ <classpath>
+ <pathelement location="${build.dir}/classes"/>
+ <path refid="client.path" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-example1b" depends="chap12-war">
+ <copy file="${chapter.dir}/hello-servlet.war"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+
+ <java dir="${build.classes.dir}" fork="yes" failOnError="true"
+ className="org.jboss.ws.client.HelloClientDII">
+
+ <jvmarg value="-Djava.endorsed.dirs=${jboss.dist}/lib/endorsed" />
+ <arg value="http://localhost:8080/hello-servlet/Hello?wsdl" />
+ <arg value="JBoss DII user" />
+ <classpath>
+ <pathelement location="${build.dir}/classes"/>
+ <path refid="client.path" />
+ </classpath>
+ </java>
+ </target>
+
+
+
+ <target name="run-example2" depends="chap12-jars">
+ <copy file="${chapter.dir}/hello-ejb.jar"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+ <java dir="${build.classes.dir}" fork="yes" failOnError="true"
+ className="org.jboss.ws.client.HelloClient">
+ <jvmarg value="-Djava.endorsed.dirs=${jboss.dist}/lib/endorsed" />
+
+ <arg value="http://localhost:8080/HelloBeanService/HelloBean?wsdl" />
+ <arg value="JBoss user" />
+ <classpath>
+ <pathelement location="${build.dir}/classes"/>
+ <path refid="client.path" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-example2b" depends="chap12-jars">
+ <copy file="${chapter.dir}/hello-ejb.jar"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+ <java dir="${build.classes.dir}" fork="yes" failOnError="true"
+ className="org.jboss.ws.client.HelloClientDII">
+
+ <jvmarg value="-Djava.endorsed.dirs=${jboss.dist}/lib/endorsed" />
+ <arg value="http://localhost:8080/HelloBeanService/HelloBean?wsdl" />
+ <arg value="JBoss DII user" />
+ <classpath>
+ <pathelement location="${build.dir}/classes"/>
+ <path refid="client.path" />
+ </classpath>
+ </java>
+ </target>
+
+
+
+
+
+ <target name="run-example3" depends="chap12-war,ch12-ex.jar">
+ <copy file="${chapter.dir}/hello-servlet.war"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+ <copy file="${chapter.dir}/ch12-ex.jar"
+ todir="${jboss.dist}/server/default/deploy"/>
+
+ <echo message="Waiting for 5 seconds for deploy..." />
+ <sleep seconds="5"/>
+
+
+ <java dir="${build.classes.dir}" fork="yes" failOnError="true"
+ className="org.jboss.ws.client.ExampleClient">
+
+ <classpath>
+ <pathelement location="${build.dir}/classes"/>
+ <path refid="client.path" />
+ </classpath>
+ </java>
+
+ </target>
+
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/build.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ JBoss 4.2 Enterprise Application Platform Server Configuration Guide
+ $Revision: 1.1 $
+-->
+<project name="JBoss book examples" default="build-all" basedir=".">
+ <!-- Allow overrides from a local properties file -->
+ <property file="ant.properties" />
+
+ <!-- Override with your JBoss server bundle dist location -->
+ <property name="jboss.dist" value="${basedir}/../../../../jboss-eap-4.3/jboss-as" />
+ <property name="jboss.deploy.conf" value="default" />
+ <property name="jboss.deploy.dir" value="${jboss.dist}/server/${jboss.deploy.conf}/deploy" />
+ <property name="src.dir" value="${basedir}/src/main" />
+ <property name="src.resources" value="${basedir}/src/resources" />
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="build.dir" value="${basedir}/output" />
+ <property name="build.src.dir" value="${basedir}/output/gen-src" />
+ <property name="build.classes.dir" value="${build.dir}/classes" />
+
+ <path id="build.path">
+ <pathelement location="${jboss.dist}/client/concurrent.jar" />
+ <pathelement location="${jboss.dist}/client/jbossall-client.jar" />
+ <pathelement location="${jboss.dist}/client/jbossws-client.jar" />
+ <pathelement location="${jboss.dist}/client/jboss-jaxrpc.jar" />
+ <pathelement location="${jboss.dist}/client/jnet.jar" />
+ <pathelement location="${jboss.dist}/client/jnp-client.jar" />
+ <pathelement location="${jboss.dist}/client/jsse.jar" />
+ <pathelement location="${jboss.dist}/client/log4j.jar" />
+ <pathelement location="${jboss.dist}/server/default/lib/javax.servlet.jar" />
+ <pathelement location="${jboss.dist}/server/default/lib/jboss.jar" />
+ <pathelement location="${jboss.dist}/server/default/lib/jbosssx.jar" />
+ <pathelement location="${jboss.dist}/server/default/lib/scheduler-plugin.jar" />
+ <pathelement location="${jboss.dist}/server/all/lib/jbossha.jar" />
+ <pathelement location="${jboss.dist}/lib/jboss-system.jar" />
+ <pathelement location="${jboss.dist}/lib/jboss-jmx.jar" />
+ <pathelement location="${lib.dir}/junit.jar" />
+ <pathelement location="${build.classes.dir}" />
+ </path>
+
+ <path id="client.path">
+ <pathelement location="${src.resources}" />
+
+ <fileset dir="${jboss.dist}/client">
+ <include name="**/*.jar" />
+ </fileset>
+
+ <pathelement location="${build.classes.dir}" />
+ </path>
+
+
+ <!--
+ Validate the jboss.dist value by looking for a the client/jboss-j2ee.jar jar
+ -->
+ <target name="validate">
+ <available property="classpath_id" value="build.path" file="${jboss.dist}/client/jboss-j2ee.jar" />
+ </target>
+
+ <target name="fail_if_not_valid" unless="classpath_id">
+ <fail message="jboss.dist=${jboss.dist} is not a valid JBoss dist directory" />
+ </target>
+
+ <target name="init" depends="validate,fail_if_not_valid">
+ <property name="classpath" refid="${classpath_id}" />
+ <echo message="Using jboss.dist=${jboss.dist}" />
+ <mkdir dir="logs" />
+ </target>
+
+ <!-- Compile all java source under src/main -->
+ <target name="compile" depends="init">
+ <mkdir dir="${build.classes.dir}" />
+ <mkdir dir="${build.src.dir}" />
+ <javac srcdir="${src.dir}"
+ destdir="${build.classes.dir}"
+ debug="on" deprecation="on"
+ optimize="off">
+ <classpath>
+ <path refid="build.path" />
+ </classpath>
+ <src path="${build.src.dir}" />
+ <!-- <include name="ListJar.java" /> -->
+ <include name="org/jboss/**" />
+ </javac>
+ </target>
+
+ <target name="build-all" depends="compile">
+ <ant antfile="build-jmx.xml" />
+ <ant antfile="build-naming.xml" />
+ <ant antfile="build-jms.xml" />
+ <ant antfile="build-jca.xml" />
+ <ant antfile="build-security.xml" />
+ <ant antfile="build-misc.xml" />
+ </target>
+
+ <target name="build-chap" depends="compile">
+ <ant antfile="build-${chap}.xml" />
+ </target>
+
+ <!-- Use -Dchap=N to run chapN-config -->
+ <target name="config" depends="compile">
+ <property name="client.path" refid="client.path" />
+ <ant antfile="build-${chap}.xml" inheritRefs="true" target="config" />
+ </target>
+
+ <!-- Use -Dchap=N -Dex=M to run chapN-exampleM -->
+ <target name="run-example" depends="compile">
+ <property name="client.path" refid="client.path" />
+ <ant antfile="build-${chap}.xml" inheritRefs="true" target="run-example${ex}" />
+ </target>
+
+ <target name="clean">
+ <delete dir="${build.dir}" />
+ <delete dir="logs" />
+ </target>
+</project>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/lib/junit.jar
===================================================================
(Binary files differ)
Property changes on: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/lib/junit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.jca.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,82 @@
+package org.jboss.book.jca.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.log4j.Category;
+
+import org.jboss.book.jca.ex1.ra.DirContextFactory;
+
+public class EchoBean
+ implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.info("echo, arg="+arg);
+ try {
+ InitialContext ctx = new InitialContext();
+ Object ref = ctx.lookup("java:comp/env/ra/DirContextFactory");
+ log.info("echo, ra/DirContextFactory=" + ref);
+
+ DirContextFactory dcf = (DirContextFactory) ref;
+ log.info("echo, found dcf=" + dcf);
+
+ DirContext dc = dcf.getConnection();
+ log.info("echo, lookup dc=" + dc);
+
+ dc.close();
+ } catch(NamingException e) {
+ log.error("Failed during JNDI access", e);
+ }
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.jca.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,25 @@
+package org.jboss.book.jca.ex1;
+
+import javax.naming.InitialContext;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[])
+ throws Exception
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+
+ System.out.println("Created Echo");
+
+ System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean</ejb-name>
+ <home>org.jboss.book.jca.ex1.EchoHome</home>
+ <remote>org.jboss.book.jca.ex1.Echo</remote>
+ <ejb-class>org.jboss.book.jca.ex1.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <resource-ref>
+ <res-ref-name>ra/DirContextFactory</res-ref-name>
+ <res-type>org.jboss.book.jca.ex1.ra.DirContextFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,45 @@
+
+<!-- The non-transaction FileSystem resource adaptor service configuration
+-->
+<server>
+ <mbean code="org.jboss.resource.connectionmanager.NoTxConnectionManager"
+ name="jboss.jca:service=NoTxCM,name=filesystem">
+ <depends>jboss.jca:service=RARDeployer</depends>
+ <depends optional-attribute-name="ManagedConnectionFactoryName">
+ <mbean code="org.jboss.resource.connectionmanager.RARDeployment"
+ name="jboss.jca:service=NoTxFS,name=filesystem">
+ <depends optional-attribute-name="OldRarDeployment">
+ jboss.jca:service=RARDeployment,name=File System Adapter
+ </depends>
+
+ <attribute name="ManagedConnectionFactoryProperties">
+ <properties>
+ <config-property>
+ <config-property-name>FileSystemRootDir</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>/tmp/db/fs_store</config-property-value>
+ </config-property>
+ </properties>
+ </attribute>
+ <attribute name="JndiName">NoTransFS</attribute>
+ </mbean>
+ </depends>
+
+ <depends optional-attribute-name="ManagedConnectionPool">
+ <mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool"
+ name="jboss.jca:service=NoTxPool,name=filesystem">
+ <attribute name="MinSize">0</attribute>
+ <attribute name="MaxSize">50</attribute>
+ <attribute name="BlockingTimeoutMillis">5000</attribute>
+ <attribute name="IdleTimeoutMinutes">15</attribute>
+ <attribute name="Criteria">ByContainer</attribute>
+ </mbean>
+ </depends>
+ <depends optional-attribute-name="CachedConnectionManager">
+ jboss.jca:service=CachedConnectionManager
+ </depends>
+ <depends optional-attribute-name="JaasSecurityManagerService">
+ jboss.security:service=JaasSecurityManager
+ </depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean</ejb-name>
+ <resource-ref>
+ <res-ref-name>ra/DirContextFactory</res-ref-name>
+ <jndi-name>java:/NoTransFS</jndi-name>
+ </resource-ref>
+ </session>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/notxfs-ds.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/notxfs-ds.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/notxfs-ds.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,17 @@
+<!DOCTYPE connection-factories PUBLIC
+ "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+<!--
+ The non-transaction FileSystem resource adaptor service configuration
+-->
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>NoTransFS</jndi-name>
+ <rar-name>jca-ex1.rar</rar-name>
+ <connection-definition>
+ org.jboss.book.jca.ex1.ra.DirContextFactory
+ </connection-definition>
+ <config-property name="FileSystemRootDir"
+ type="java.lang.String">/tmp/db/fs_store</config-property>
+ </no-tx-connection-factory>
+</connection-factories>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactory.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactory.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactory.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,19 @@
+package org.jboss.book.jca.ex1.ra;
+
+import java.io.Serializable;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.resource.Referenceable;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface DirContextFactory
+ extends Referenceable,
+ Serializable
+{
+ public DirContext getConnection()
+ throws NamingException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactoryImpl.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactoryImpl.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/DirContextFactoryImpl.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,76 @@
+package org.jboss.book.jca.ex1.ra;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.directory.DirContext;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import org.apache.log4j.Category;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class DirContextFactoryImpl implements DirContextFactory
+{
+ static Category log = Category.getInstance(DirContextFactoryImpl.class);
+ private transient ConnectionManager manager;
+ private transient ManagedConnectionFactory factory;
+ private transient FSRequestInfo fsInfo;
+ private Reference reference;
+
+ DirContextFactoryImpl(ConnectionManager manager,
+ ManagedConnectionFactory factory, FSRequestInfo fsInfo)
+ {
+ this.manager = manager;
+ this.factory = factory;
+ this.fsInfo = fsInfo;
+ log.debug("ctor, fsInfo="+fsInfo);
+ }
+
+ public DirContext getConnection() throws NamingException
+ {
+ log.debug("getConnection", new Exception("CalledBy:"));
+ DirContext dc = null;
+ try
+ {
+ dc = (DirContext) manager.allocateConnection(factory, fsInfo);
+ }
+ catch(ResourceException e)
+ {
+ throw new NamingException("Unable to get Connection: "+e);
+ }
+ return dc;
+ }
+ public DirContext getConnection(String user, String password) throws NamingException
+ {
+ log.debug("getConnection, user="+user);
+ DirContext dc = null;
+ try
+ {
+ dc = (DirContext) manager.allocateConnection(factory, fsInfo);
+ }
+ catch(ResourceException e)
+ {
+ throw new NamingException("Unable to get Connection: "+e);
+ }
+ return dc;
+ }
+
+ public void setReference(Reference reference)
+ {
+ log.debug("setReference, reference="+reference, new Exception("CalledBy:"));
+ this.reference = reference;
+ }
+
+ public Reference getReference() throws NamingException
+ {
+ log.debug("getReference");
+ return reference;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSDirContext.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSDirContext.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSDirContext.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,295 @@
+package org.jboss.book.jca.ex1.ra;
+
+import java.util.Hashtable;
+import javax.naming.Name;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NameParser;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.Attributes;
+
+import org.apache.log4j.Category;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class FSDirContext implements DirContext
+{
+ static Category log = Category.getInstance(FSDirContext.class);
+ FSManagedConnection mc;
+
+ /** Creates new FSDirContext */
+ public FSDirContext(FSManagedConnection mc)
+ {
+ this.mc = mc;
+ }
+
+ protected void setManagedConnection(FSManagedConnection mc)
+ {
+ this.mc = mc;
+ }
+
+ public Attributes getAttributes(Name name, String[] str) throws NamingException
+ {
+ return null;
+ }
+
+ public void close() throws NamingException
+ {
+ log.debug("close");
+ mc.close();
+ }
+
+ public NamingEnumeration list(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ }
+
+ public DirContext getSchemaClassDefinition(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public DirContext createSubcontext(String str, Attributes attributes) throws NamingException
+ {
+ return null;
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ return null;
+ }
+
+ public Object addToEnvironment(String str, Object obj) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ }
+
+ public NamingEnumeration search(String str, Attributes attributes, String[] str2) throws NamingException
+ {
+ return null;
+ }
+
+ public void modifyAttributes(Name name, int param, Attributes attributes) throws NamingException
+ {
+ }
+
+ public Hashtable getEnvironment() throws NamingException
+ {
+ return null;
+ }
+
+ public void bind(String str, Object obj) throws NamingException
+ {
+ }
+
+ public void rebind(String str, Object obj, Attributes attributes) throws NamingException
+ {
+ }
+
+ public DirContext getSchema(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public DirContext getSchemaClassDefinition(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public Object lookup(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void destroySubcontext(String str) throws NamingException
+ {
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public Object lookupLink(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public DirContext getSchema(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public Object lookup(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ }
+
+ public NamingEnumeration listBindings(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void rebind(String str, Object obj) throws NamingException
+ {
+ }
+
+ public Object removeFromEnvironment(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void bind(String str, Object obj, Attributes attributes) throws NamingException
+ {
+ }
+
+ public NamingEnumeration search(Name name, Attributes attributes) throws NamingException
+ {
+ return null;
+ }
+
+ public NameParser getNameParser(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void bind(Name name, Object obj, Attributes attributes) throws NamingException
+ {
+ }
+
+ public Attributes getAttributes(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void rename(String str, String str1) throws NamingException
+ {
+ }
+
+ public void rename(Name name, Name name1) throws NamingException
+ {
+ }
+
+ public DirContext createSubcontext(Name name, Attributes attributes) throws NamingException
+ {
+ return null;
+ }
+
+ public void rebind(Name name, Object obj, Attributes attributes) throws NamingException
+ {
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public Context createSubcontext(String str) throws NamingException
+ {
+ return null;
+ }
+
+ public void modifyAttributes(String str, int param, Attributes attributes) throws NamingException
+ {
+ }
+
+ public NamingEnumeration search(String str, Attributes attributes) throws NamingException
+ {
+ return null;
+ }
+
+ public Name composeName(Name name, Name name1) throws NamingException
+ {
+ return null;
+ }
+
+ public String composeName(String str, String str1) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration search(Name name, Attributes attributes, String[] str) throws NamingException
+ {
+ return null;
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ }
+
+ public void modifyAttributes(Name name, ModificationItem[] modificationItem) throws NamingException
+ {
+ }
+
+ public NamingEnumeration search(Name name, String str, SearchControls searchControls) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration search(Name name, String str, Object[] obj, SearchControls searchControls) throws NamingException
+ {
+ return null;
+ }
+
+ public void unbind(String str) throws NamingException
+ {
+ }
+
+ public void modifyAttributes(String str, ModificationItem[] modificationItem) throws NamingException
+ {
+ }
+
+ public Attributes getAttributes(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public Attributes getAttributes(String str, String[] str1) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration search(String str, String str1, SearchControls searchControls) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration search(String str, String str1, Object[] obj, SearchControls searchControls) throws NamingException
+ {
+ return null;
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnection.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnection.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnection.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,119 @@
+package org.jboss.book.jca.ex1.ra;
+
+import java.util.ArrayList;
+import javax.resource.ResourceException;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+import java.io.PrintWriter;
+
+import org.apache.log4j.Category;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class FSManagedConnection implements ManagedConnection
+{
+ static Category log = Category.getInstance(FSManagedConnection.class);
+ ArrayList listeners = new ArrayList();
+ FSDirContext conn;
+
+ /** Creates new FSManagedConnection */
+ public FSManagedConnection(Subject subject,
+ FSRequestInfo fsInfo)
+ {
+ log.debug("ctor, fsInfo="+fsInfo);
+ }
+
+ public void addConnectionEventListener(ConnectionEventListener connectionEventListener)
+ {
+ log.debug("addConnectionEventListener, listener="+connectionEventListener,
+ new Exception("CalledBy:"));
+ listeners.add(connectionEventListener);
+ }
+ public void removeConnectionEventListener(ConnectionEventListener connectionEventListener)
+ {
+ log.debug("removeConnectionEventListener, listener="+connectionEventListener,
+ new Exception("CalledBy:"));
+ listeners.remove(connectionEventListener);
+ }
+
+ public void associateConnection(Object obj) throws ResourceException
+ {
+ log.debug("associateConnection, obj="+obj, new Exception("CalledBy:"));
+ conn = (FSDirContext) obj;
+ conn.setManagedConnection(this);
+ }
+
+ public void cleanup() throws ResourceException
+ {
+ log.debug("cleanup");
+ }
+
+ public void destroy() throws ResourceException
+ {
+ log.debug("destroy");
+ }
+
+ public Object getConnection(Subject subject, ConnectionRequestInfo info)
+ throws ResourceException
+ {
+ log.debug("getConnection, subject="+subject+", info="+info,
+ new Exception("CalledBy:"));
+ if( conn == null )
+ conn = new FSDirContext(this);
+ return conn;
+ }
+
+ public LocalTransaction getLocalTransaction() throws ResourceException
+ {
+ log.debug("getLocalTransaction");
+ return null;
+ }
+
+ public ManagedConnectionMetaData getMetaData() throws ResourceException
+ {
+ log.debug("getMetaData");
+ return new FSManagedConnectionMetaData();
+ }
+
+ public XAResource getXAResource() throws ResourceException
+ {
+ log.debug("getXAResource");
+ return null;
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ return null;
+ }
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ }
+
+ protected void close()
+ {
+ ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+ ce.setConnectionHandle(conn);
+ fireConnectionEvent(ce);
+ }
+
+ protected void fireConnectionEvent(ConnectionEvent evt)
+ {
+ for(int i=listeners.size()-1; i >= 0; i--)
+ {
+ ConnectionEventListener listener = (ConnectionEventListener) listeners.get(i);
+ if(evt.getId() == ConnectionEvent.CONNECTION_CLOSED)
+ listener.connectionClosed(evt);
+ else if(evt.getId() == ConnectionEvent.CONNECTION_ERROR_OCCURRED)
+ listener.connectionErrorOccurred(evt);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionFactory.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionFactory.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionFactory.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,102 @@
+package org.jboss.book.jca.ex1.ra;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.util.Set;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+import org.apache.log4j.Category;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class FSManagedConnectionFactory
+ implements ManagedConnectionFactory,
+ Serializable
+{
+ static Category log = Category.getInstance(FSManagedConnectionFactory.class);
+ private String rootDirPath;
+ private transient File rootDir;
+
+ /** Creates new FSManagedConnectionFactory */
+ public FSManagedConnectionFactory()
+ {
+ }
+
+ public Object createConnectionFactory()
+ throws ResourceException
+ {
+ log.debug("createConnectionFactory");
+ throw new UnsupportedOperationException("Cannot be used in unmanaged env");
+ }
+
+ public Object createConnectionFactory(ConnectionManager cm)
+ throws ResourceException
+ {
+ log.debug("createConnectionFactory, cm=" + cm, new Exception("CalledBy:"));
+ FSRequestInfo fsInfo = new FSRequestInfo(rootDir);
+ return new DirContextFactoryImpl(cm, this, fsInfo);
+ }
+
+ public ManagedConnection createManagedConnection(Subject subject,
+ ConnectionRequestInfo info)
+ throws ResourceException
+ {
+ log.debug("createManagedConnection, subject=" + subject + ", info=" + info,
+ new Exception("CalledBy:"));
+ FSRequestInfo fsInfo = (FSRequestInfo) info;
+ return new FSManagedConnection(subject, fsInfo);
+ }
+
+ public ManagedConnection matchManagedConnections(Set connectionSet,
+ Subject subject,
+ ConnectionRequestInfo info)
+ throws ResourceException
+ {
+ log.debug("matchManagedConnections, connectionSet=" +
+ connectionSet + ", subject=" + subject +", info=" +info);
+ return (ManagedConnection) connectionSet.iterator().next();
+ }
+
+ public PrintWriter getLogWriter()
+ throws ResourceException
+ {
+ return null;
+ }
+
+
+ public void setLogWriter(PrintWriter out)
+ throws ResourceException
+ {
+ }
+
+ public boolean equals(Object other)
+ {
+ return super.equals(other);
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public void setFileSystemRootDir(String rootDirPath)
+ {
+ this.rootDirPath = rootDirPath;
+ rootDir = new File(rootDirPath);
+
+ if (rootDir.exists() == false) {
+ rootDir.mkdirs();
+ }
+ log.debug("setFileSystemRootDir, rootDir=" + rootDir.getAbsolutePath(),
+ new Exception("CalledBy:"));
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionMetaData.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionMetaData.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSManagedConnectionMetaData.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,44 @@
+/*
+ * FSManagedConnectionMetaData.java
+ *
+ * Created on October 31, 2001, 8:04 PM
+ */
+
+package org.jboss.book.jca.ex1.ra;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionMetaData;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version
+ */
+public class FSManagedConnectionMetaData implements ManagedConnectionMetaData
+{
+ /** Creates new FSManagedConnectionMetaData */
+ public FSManagedConnectionMetaData()
+ {
+ }
+
+ public String getEISProductName() throws ResourceException
+ {
+ return "Local File System Adaptor";
+ }
+
+ public String getEISProductVersion() throws ResourceException
+ {
+ return "JBoss 2.4.x JCA";
+ }
+
+ public int getMaxConnections() throws ResourceException
+ {
+ return 100;
+ }
+
+ public String getUserName() throws ResourceException
+ {
+ return "nobody";
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSRequestInfo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSRequestInfo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/FSRequestInfo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,35 @@
+package org.jboss.book.jca.ex1.ra;
+
+import java.io.File;
+import javax.resource.spi.ConnectionRequestInfo;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class FSRequestInfo implements ConnectionRequestInfo
+{
+ private File rootDir;
+
+ /** Creates new FSRequestInfo */
+ public FSRequestInfo(File rootDir)
+ {
+ this.rootDir = rootDir;
+ }
+
+ public boolean equals(Object obj)
+ {
+ FSRequestInfo info = (FSRequestInfo) obj;
+ return rootDir.equals(info.rootDir);
+ }
+
+ public int hashCode()
+ {
+ return rootDir.hashCode();
+ }
+ public String toString()
+ {
+ return "[FSRequestInfo, rootDir="+rootDir.getAbsolutePath()+"]";
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/ra.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/ra.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/ex1/ra/ra.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" version="1.5">
+ <display-name>File System Adapter</display-name>
+ <vendor-name>JBoss</vendor-name>
+ <eis-type>FileSystem</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>LGPL</description>
+ <license-required>false</license-required>
+ </license>
+ <resourceadapter>
+
+ <resourceadapter-class>org.jboss.resource.deployment.DummyResourceAdapter</resourceadapter-class>
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>
+ org.jboss.book.jca.ex1.ra.FSManagedConnectionFactory
+ </managedconnectionfactory-class>
+ <config-property>
+ <config-property-name>FileSystemRootDir</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>/tmp/db/fs_store</config-property-value>
+ </config-property>
+ <config-property>
+ <config-property-name>UserName</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value/>
+ </config-property>
+ <config-property>
+ <config-property-name>Password</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value/>
+ </config-property>
+ <connectionfactory-interface>
+ org.jboss.book.jca.ex1.ra.DirContextFactory </connectionfactory-interface>
+ <connectionfactory-impl-class>
+ org.jboss.book.jca.ex1.ra.DirContextFactoryImpl </connectionfactory-impl-class>
+ <connection-interface> javax.naming.directory.DirContext </connection-interface>
+ <connection-impl-class> org.jboss.book.jca.ex1.ra.FSDirContext </connection-impl-class>
+ </connection-definition>
+ <transaction-support>NoTransaction</transaction-support>
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>true</reauthentication-support>
+ </outbound-resourceadapter>
+ <security-permission>
+ <description> Read/Write access is required to the contents of the
+ FileSystemRootDir </description>
+ <security-permission-spec> permission java.io.FilePermission
+ "/tmp/db/fs_store/*", "read,write"; </security-permission-spec>
+ </security-permission>
+ </resourceadapter>
+</connector>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/log4j.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/log4j.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jca/log4j.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,31 @@
+# A log4j properties file suitable for replacing the
+# default JBoss ConsoleLogging & FileLogging mbeans.
+
+log4j.rootCategory=DEBUG, Default, Console
+
+### The server.log file appender
+log4j.appender.Default=org.apache.log4j.RollingFileAppender
+log4j.appender.Default.File=../log/server.log
+log4j.appender.Default.MaxFileSize=500KB
+log4j.appender.Default.MaxBackupIndex=1
+log4j.appender.Default.layout=org.apache.log4j.PatternLayout
+# Use the default JBoss format
+log4j.appender.Default.layout.ConversionPattern=[%d{ABSOLUTE},%c{1}] %m%n
+# Truncate if it aleady exists.
+log4j.appender.Default.Append=false
+#Example of turning off logging for a category. Uncomment to turn off.
+#log4j.category.DefaultDS=FATAL
+
+### The console appender
+log4j.appender.Console=org.jboss.logging.log4j.ConsoleAppender
+log4j.appender.Console.Threshold=INFO
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.ConversionPattern=[%p,%c{1}] %m%n
+
+### The example
+log4j.appender.mylog=org.apache.log4j.FileAppender
+log4j.appender.mylog.File=../log/jca.log
+log4j.appender.mylog.layout=org.apache.log4j.PatternLayout
+log4j.appender.mylog.layout.ConversionPattern=[%c{1}] %m%n
+log4j.appender.mylog.Append=false
+log4j.category.org.jboss.book.jca=DEBUG, mylog
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,99 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+
+/** A complete JMS client example program that sends a
+TextMessage to a Queue and asynchronously receives the
+message from the same Queue.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class DurableTopicClient
+{
+ static CountDown done = new CountDown(1);
+ TopicConnection conn = null;
+ TopicSession session = null;
+ Topic topic = null;
+
+ public static class ExListener implements MessageListener
+ {
+ public void onMessage(Message msg)
+ {
+ done.release();
+ TextMessage tm = (TextMessage) msg;
+ try
+ {
+ System.out.println("onMessage, recv text="
+ + tm.getText());
+ }
+ catch(Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public void setupPubSub()
+ throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("TopicConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ conn = tcf.createTopicConnection("jduke", "theduke");
+ conn.setClientID("OtherSubscriptions");
+ topic = (Topic) iniCtx.lookup("topic/testTopic");
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendRecvAsync(String text)
+ throws JMSException, NamingException
+ {
+ System.out.println("Begin sendRecvAsync");
+ // Setup the pub/sub connection, session
+ setupPubSub();
+ // Set the async listener
+ TopicSubscriber recv = session.createDurableSubscriber(topic, "AnotherExample");
+ recv.setMessageListener(new ExListener());
+ // Send a text msg
+ TopicPublisher send = session.createPublisher(topic);
+ TextMessage tm = session.createTextMessage(text);
+ send.publish(tm);
+ System.out.println("sendRecvAsync, sent text="
+ + tm.getText());
+ send.close();
+ System.out.println("End sendRecvAsync");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ DurableTopicClient client = new DurableTopicClient();
+ client.sendRecvAsync("A text msg");
+ client.done.acquire();
+ client.stop();
+ System.exit(0);
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,80 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A JMS client example program that synchronously receives a message a Topic
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class DurableTopicRecvClient
+{
+ TopicConnection conn = null;
+ TopicSession session = null;
+ Topic topic = null;
+
+ public void setupPubSub()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ conn = tcf.createTopicConnection("john", "needle");
+ topic = (Topic) iniCtx.lookup("topic/testTopic");
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void recvSync()
+ throws JMSException,
+ NamingException
+ {
+ System.out.println("Begin recvSync");
+ // Setup the pub/sub connection, session
+
+ setupPubSub();
+ // Wait upto 5 seconds for the message
+ TopicSubscriber recv =
+ session.createDurableSubscriber(topic, "jms-ex1dtps");
+ Message msg = recv.receive(5000);
+ if (msg == null) {
+ System.out.println("Timed out waiting for msg");
+ } else {
+ System.out.println("DurableTopicRecvClient.recv, msgt=" + msg);
+ }
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ System.out.println("Begin DurableTopicRecvClient, now=" +
+ System.currentTimeMillis());
+ DurableTopicRecvClient client = new DurableTopicRecvClient();
+ client.recvSync();
+ client.stop();
+ System.out.println("End DurableTopicRecvClient");
+ System.exit(0);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicSetup.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicSetup.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/DurableTopicSetup.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,41 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.naming.InitialContext;
+
+/** A client that creates a durable topic subscriber and exits simply to
+create the durable topic using the JBossMQ dynamic durable topic capability.
+
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class DurableTopicSetup
+{
+
+ public static void main(String args[]) throws Exception
+ {
+ System.out.println("Begin DurableTopicSetup");
+ InitialContext iniCtx = new InitialContext();
+
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ TopicConnection conn = tcf.createTopicConnection("john", "needle");
+ Topic topic = (Topic) iniCtx.lookup("topic/testTopic");
+ TopicSession session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+
+ TopicSubscriber recv = session.createDurableSubscriber(topic, "jms-ex1dtps");
+ session.createSubscriber(topic);
+
+ conn.close();
+ System.out.println("End DurableTopicSetup");
+ System.exit(0);
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/SendRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/SendRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/SendRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,109 @@
+package org.jboss.book.jms.ex1;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+import org.apache.log4j.Logger;
+import org.jboss.util.ChapterExRepository;
+
+ /**
+ * A complete JMS client example program that sends a
+ * TextMessage to a Queue and asynchronously receives the
+ * message from the same Queue.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+
+public class SendRecvClient {
+ static Logger log;
+ static CountDown done = new CountDown(1);
+
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+ public static class ExListener
+ implements MessageListener
+ {
+ public void onMessage(Message msg) {
+ done.release();
+ TextMessage tm = (TextMessage) msg;
+ try {
+ log.info("onMessage, recv text=" + tm.getText());
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public void setupPTP()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/testQueue");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendRecvAsync(String text)
+ throws JMSException,
+ NamingException
+ {
+ log.info("Begin sendRecvAsync");
+ // Setup the PTP connection, session
+
+ setupPTP();
+
+ // Set the async listener
+ QueueReceiver recv = session.createReceiver(que);
+
+ recv.setMessageListener(new ExListener());
+
+ // Send a text msg
+ QueueSender send = session.createSender(que);
+
+ TextMessage tm = session.createTextMessage(text);
+ send.send(tm);
+ log.info("sendRecvAsync, sent text=" + tm.getText());
+ send.close();
+ log.info("End sendRecvAsync");
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ ChapterExRepository.init(SendRecvClient.class);
+ log = Logger.getLogger("SendRecvClient");
+ log.info("Begin SendRecvClient, now=" + System.currentTimeMillis());
+ SendRecvClient client = new SendRecvClient();
+ client.sendRecvAsync("A text msg");
+ client.done.acquire();
+ client.stop();
+ log.info("End SendRecvClient");
+ System.exit(0);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,79 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A JMS client example program that synchronously receives a message a Topic
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TopicRecvClient
+{
+ TopicConnection conn = null;
+ TopicSession session = null;
+ Topic topic = null;
+
+ public void setupPubSub()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ conn = tcf.createTopicConnection();
+ topic = (Topic) iniCtx.lookup("topic/testTopic");
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void recvSync()
+ throws JMSException,
+ NamingException
+ {
+ System.out.println("Begin recvSync");
+ // Setup the pub/sub connection, session
+ setupPubSub();
+ // Wait upto 5 seconds for the message
+ TopicSubscriber recv = session.createSubscriber(topic);
+ Message msg = recv.receive(5000);
+ if (msg == null) {
+ System.out.println("Timed out waiting for msg");
+ } else {
+ System.out.println("TopicSubscriber.recv, msgt=" + msg);
+ }
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ System.out.println("Begin TopicRecvClient, now=" +
+ System.currentTimeMillis());
+ TopicRecvClient client = new TopicRecvClient();
+ client.recvSync();
+ client.stop();
+ System.out.println("End TopicRecvClient");
+ System.exit(0);
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,76 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/** A JMS client example program that sends a TextMessage to a Topic
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TopicSendClient
+{
+ TopicConnection conn = null;
+ TopicSession session = null;
+ Topic topic = null;
+
+ public void setupPubSub()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ conn = tcf.createTopicConnection();
+ topic = (Topic) iniCtx.lookup("topic/testTopic");
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendAsync(String text)
+ throws JMSException,
+ NamingException
+ {
+ System.out.println("Begin sendAsync");
+ // Setup the pub/sub connection, session
+ setupPubSub();
+
+ // Send a text msg
+ TopicPublisher send = session.createPublisher(topic);
+ TextMessage tm = session.createTextMessage(text);
+ send.publish(tm);
+ System.out.println("sendAsync, sent text=" + tm.getText());
+ send.close();
+ System.out.println("End sendAsync");
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ System.out.println("Begin TopicSendClient, now="+System.currentTimeMillis());
+
+ TopicSendClient client = new TopicSendClient();
+ client.sendAsync("A text msg, now="+System.currentTimeMillis());
+ client.stop();
+ System.out.println("End TopicSendClient");
+ System.exit(0);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/TopicSendRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,103 @@
+package org.jboss.book.jms.ex1;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+
+/** A complete JMS client example program that sends a
+TextMessage to a Topic and asynchronously receives the
+message from the same Topic.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class TopicSendRecvClient
+{
+ static CountDown done = new CountDown(1);
+ TopicConnection conn = null;
+ TopicSession session = null;
+ Topic topic = null;
+
+ public static class ExListener
+ implements MessageListener
+ {
+ public void onMessage(Message msg)
+ {
+ done.release();
+ TextMessage tm = (TextMessage) msg;
+ try {
+ System.out.println("onMessage, recv text=" + tm.getText());
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public void setupPubSub()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+ conn = tcf.createTopicConnection();
+ topic = (Topic) iniCtx.lookup("topic/testTopic");
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendRecvAsync(String text)
+ throws JMSException,
+ NamingException
+ {
+ System.out.println("Begin sendRecvAsync");
+ // Setup the PubSub connection, session
+ setupPubSub();
+
+ // Set the async listener
+ TopicSubscriber recv = session.createSubscriber(topic);
+ recv.setMessageListener(new ExListener());
+ // Send a text msg
+ TopicPublisher send = session.createPublisher(topic);
+ TextMessage tm = session.createTextMessage(text);
+ send.publish(tm);
+ System.out.println("sendRecvAsync, sent text=" + tm.getText());
+ send.close();
+ System.out.println("End sendRecvAsync");
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ System.out.println("Begin TopicSendRecvClient, now=" +
+ System.currentTimeMillis());
+
+ TopicSendRecvClient client = new TopicSendRecvClient();
+ client.sendRecvAsync("A text msg, now="+System.currentTimeMillis());
+ client.done.acquire();
+ client.stop();
+
+ System.out.println("End TopicSendRecvClient");
+ System.exit(0);
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/log4j.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/log4j.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex1/log4j.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="logs/${chapter.ex}.log"/>
+ <param name="Append" value="false"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.mq">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+
+ <root>
+ <level value="DEBUG"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+</log4j:configuration>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/SendRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/SendRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/SendRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,108 @@
+package org.jboss.book.jms.ex2;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+
+/**
+ * A complete JMS client example program that sends N TextMessages to
+ * a Queue B and asynchronously receives the messages as modified by
+ * TextMDB from Queue A.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class SendRecvClient
+{
+ static final int N = 10;
+ static CountDown done = new CountDown(N);
+ QueueConnection conn;
+ QueueSession session;
+ Queue queA;
+ Queue queB;
+
+ public static class ExListener
+ implements MessageListener
+ {
+ public void onMessage(Message msg)
+ {
+ done.release();
+ TextMessage tm = (TextMessage) msg;
+ try {
+ System.out.println("onMessage, recv text=" +
+ tm.getText());
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public void setupPTP()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("UIL2ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+
+ conn = qcf.createQueueConnection();
+ queA = (Queue) iniCtx.lookup("queue/A");
+ queB = (Queue) iniCtx.lookup("queue/B");
+ session = conn.createQueueSession(false,
+ QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendRecvAsync(String textBase)
+ throws JMSException,
+ NamingException,
+ InterruptedException
+ {
+ System.out.println("Begin sendRecvAsync");
+ // Setup the PTP connection, session
+ setupPTP();
+
+ // Set the async listener for queA
+ QueueReceiver recv = session.createReceiver(queA);
+ recv.setMessageListener(new ExListener());
+
+ // Send a few text msgs to queB
+ QueueSender send = session.createSender(queB);
+ for(int m = 0; m < N; m ++) {
+ TextMessage tm = session.createTextMessage(textBase + "#" + m);
+ tm.setJMSReplyTo(queA);
+ send.send(tm);
+ System.out.println("sendRecvAsync, sent text=" + tm.getText());
+ }
+ System.out.println("End sendRecvAsync");
+ }
+
+ public void stop()
+ throws JMSException
+ {
+ conn.close();
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ System.out.println("Begin SendRecvClient, now="+System.currentTimeMillis());
+ SendRecvClient client = new SendRecvClient();
+ client.sendRecvAsync("A text msg");
+ client.done.acquire();
+ client.stop();
+ System.exit(0);
+ System.out.println("End SendRecvClient");
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/TextMDB.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/TextMDB.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/TextMDB.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,116 @@
+package org.jboss.book.jms.ex2;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.EJBException;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * An MDB that transforms the TextMessages it receives and send the
+ * transformed messages to the Queue found in the incoming message
+ * JMSReplyTo header.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TextMDB
+ implements MessageDrivenBean,
+ MessageListener
+{
+ private static Logger log = Logger.getLogger(TextMDB.class);
+
+ private MessageDrivenContext ctx = null;
+ private QueueConnection conn;
+ private QueueSession session;
+
+ public TextMDB()
+ {
+ log.info("TextMDB.ctor, this=" + hashCode());
+ log.debug("ctor.StackTrace", new Throwable("ctor"));
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ {
+ this.ctx = ctx;
+ log.info("TextMDB.setMessageDrivenContext, this=" + hashCode());
+ }
+
+ public void ejbCreate()
+ {
+ log.info("TextMDB.ejbCreate, this="+hashCode());
+ try {
+ setupPTP();
+ } catch(Exception e) {
+ log.error("Failed to init TextMDB", e);
+ throw new EJBException("Failed to init TextMDB", e);
+ }
+ }
+
+ public void ejbRemove()
+ {
+ log.info("TextMDB.ejbRemove, this=" + hashCode());
+ ctx = null;
+ try {
+ if (session != null) {
+ session.close();
+ }
+ if (conn != null) {
+ conn.close();
+ }
+ } catch(JMSException e) {
+ log.error("ejbRemove error", e);
+ }
+ }
+
+ public void onMessage(Message msg)
+ {
+ log.info("TextMDB.onMessage, this="+hashCode());
+ try {
+ TextMessage tm = (TextMessage) msg;
+ String text = tm.getText() + "processed by: " + hashCode();
+ Queue dest = (Queue) msg.getJMSReplyTo();
+ sendReply(text, dest);
+ } catch(Throwable t) {
+ log.error("onMessage error", t);
+ }
+ }
+
+ private void setupPTP()
+ throws JMSException,
+ NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("java:comp/env/jms/QCF");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ session = conn.createQueueSession(false,
+ QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ private void sendReply(String text, Queue dest)
+ throws JMSException
+ {
+ log.info("TextMDB.sendReply, this=" + hashCode() +
+ ", dest=" + dest);
+
+ QueueSender sender = session.createSender(dest);
+ TextMessage tm = session.createTextMessage(text);
+
+ sender.send(tm);
+ sender.close();
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TextMDB</ejb-name>
+ <ejb-class>org.jboss.book.jms.ex2.TextMDB</ejb-class>
+ <transaction-type>Container</transaction-type>
+ <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
+ <message-driven-destination>
+ <destination-type>javax.jms.Queue</destination-type>
+ </message-driven-destination>
+ <resource-ref>
+ <res-ref-name>jms/QCF</res-ref-name>
+ <res-type>javax.jms.QueueConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex2/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<jboss>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TextMDB</ejb-name>
+ <destination-jndi-name>queue/B</destination-jndi-name>
+ <resource-ref>
+ <res-ref-name>jms/QCF</res-ref-name>
+ <jndi-name>ConnectionFactory</jndi-name>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/SendRecvClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/SendRecvClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/SendRecvClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,101 @@
+package org.jboss.book.jms.ex3;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSubscriber;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import EDU.oswego.cs.dl.util.concurrent.CountDown;
+
+/** A complete JMS client example program that sends N
+TextMessages to a Topic A and asynchronously receives the
+messages as modified by TestMDB from Topic B.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class SendRecvClient
+{
+ static final int N = 10;
+ static CountDown done = new CountDown(N);
+ TopicConnection conn;
+ TopicSession session;
+ Topic topicA;
+ Topic topicB;
+
+ public static class ExListener implements MessageListener
+ {
+ public void onMessage(Message msg)
+ {
+ done.release();
+ TextMessage tm = (TextMessage) msg;
+ try
+ {
+ System.out.println("onMessage, recv text="+tm.getText());
+ }
+ catch(Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public void setupPubSub()
+ throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ TopicConnectionFactory qcf = (TopicConnectionFactory) tmp;
+ conn = qcf.createTopicConnection();
+ topicA = (Topic) iniCtx.lookup("topic/jms.ex3.TopicA");
+ topicB = (Topic) iniCtx.lookup("topic/jms.ex3.TopicB");
+
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+
+ public void sendRecvAsync(String textBase)
+ throws JMSException, NamingException, InterruptedException
+ {
+ System.out.println("Begin sendRecvAsync");
+ // Setup the PTP connection, session
+ setupPubSub();
+ // Set the async listener for topicA
+ TopicSubscriber recv = session.createSubscriber(topicA);
+ recv.setMessageListener(new ExListener());
+ // Send a few text msgs to topicB
+ TopicPublisher send = session.createPublisher(topicB);
+ for(int m = 0; m < 10; m ++)
+ {
+ TextMessage tm = session.createTextMessage(textBase+"#"+m);
+ tm.setJMSReplyTo(topicA);
+ send.publish(tm);
+ System.out.println("sendRecvAsync, sent text="+tm.getText());
+ }
+ System.out.println("End sendRecvAsync");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ }
+
+ public static void main(String args[]) throws Exception
+ {
+ SendRecvClient client = new SendRecvClient();
+ client.sendRecvAsync("A text msg");
+ client.done.acquire();
+ client.stop();
+ System.exit(0);
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/TextMDB.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/TextMDB.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/TextMDB.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,114 @@
+package org.jboss.book.jms.ex3;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.EJBException;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+/** An MDB that transforms the TextMessages it receives and send the transformed
+ messages to the Topic found in the incoming message JMSReplyTo header.
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public class TextMDB implements MessageDrivenBean, MessageListener
+{
+ private static Logger log = Logger.getLogger(TextMDB.class);
+
+ private MessageDrivenContext ctx = null;
+ private TopicConnection conn;
+ private TopicSession session;
+
+ public TextMDB()
+ {
+ log.info("TextMDB.ctor, this="+hashCode());
+ log.debug("ctor.StackTrace", new Throwable("ctor"));
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ {
+ this.ctx = ctx;
+ log.info("TextMDB.setMessageDrivenContext, this="+hashCode());
+ }
+
+ public void ejbCreate()
+ {
+ log.info("TextMDB.ejbCreate, this="+hashCode());
+ try
+ {
+ setupPTP();
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to init TextMDB", e);
+ throw new EJBException("Failed to init TextMDB", e);
+ }
+ }
+ public void ejbRemove()
+ {
+ log.info("TextMDB.ejbRemove, this="+hashCode());
+ ctx = null;
+ try
+ {
+ if( session != null )
+ session.close();
+ if( conn != null )
+ conn.close();
+ }
+ catch(JMSException e)
+ {
+ log.error("ejbRemove error", e);
+ }
+ }
+
+ public void onMessage(Message msg)
+ {
+ log.info("TextMDB.onMessage, this="+hashCode());
+ try
+ {
+ TextMessage tm = (TextMessage) msg;
+ String text = tm.getText() + "processed by: "+hashCode();
+ Topic dest = (Topic) msg.getJMSReplyTo();
+ sendReply(text, dest);
+ }
+ catch(Throwable t)
+ {
+ log.error("onMessage error", t);
+ }
+ }
+
+ private void setupPTP()
+ throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("java:comp/env/jms/TCF");
+ TopicConnectionFactory qcf = (TopicConnectionFactory) tmp;
+ conn = qcf.createTopicConnection();
+ session = conn.createTopicSession(false,
+ TopicSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ }
+ private void sendReply(String text, Topic dest)
+ throws JMSException
+ {
+ log.info("TextMDB.sendReply, this="+hashCode()
+ +", dest="+dest);
+ TopicPublisher sender = session.createPublisher(dest);
+ TextMessage tm = session.createTextMessage(text);
+ sender.publish(tm);
+ sender.close();
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+<ejb-jar>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TextMDB</ejb-name>
+ <ejb-class>org.jboss.book.jms.ex3.TextMDB</ejb-class>
+ <transaction-type>Container</transaction-type>
+ <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
+ <message-driven-destination>
+ <destination-type>javax.jms.Topic</destination-type>
+ <subscription-durability>Durable</subscription-durability>
+ </message-driven-destination>
+ <resource-ref>
+ <res-ref-name>jms/TCF</res-ref-name>
+ <res-type>javax.jms.TopicConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jms/ex3/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<jboss>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TextMDB</ejb-name>
+ <destination-jndi-name>topic/jms.ex3.TopicB</destination-jndi-name>
+ <mdb-user>john</mdb-user>
+ <mdb-passwd>needle</mdb-passwd>
+ <mdb-subscription-id>JMSEx3</mdb-subscription-id>
+ <resource-ref>
+ <res-ref-name>jms/TCF</res-ref-name>
+ <jndi-name>ConnectionFactory</jndi-name>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/Ex0URLClassLoader.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/Ex0URLClassLoader.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/Ex0URLClassLoader.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,56 @@
+package org.jboss.book.jmx.ex0;
+
+import java.net.URLClassLoader;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+/** A custom class loader that overrides the standard parent delegation model
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class Ex0URLClassLoader extends URLClassLoader
+{
+
+ private static Logger log = Logger.getLogger(Ex0URLClassLoader.class);
+ private Ex0URLClassLoader delegate;
+
+ public Ex0URLClassLoader(URL[] urls)
+ {
+ super(urls);
+ }
+
+ void setDelegate(Ex0URLClassLoader delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ protected synchronized Class loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ Class clazz = null;
+ if( delegate != null )
+ {
+ log.debug(Integer.toHexString(hashCode())+"; Asking delegate to loadClass: "+name);
+ clazz = delegate.loadClass(name, resolve);
+ log.debug(Integer.toHexString(hashCode())+"; Delegate returned: "+clazz);
+ }
+ else
+ {
+ log.debug(Integer.toHexString(hashCode())+"; Asking super to loadClass: "+name);
+ clazz = super.loadClass(name, resolve);
+ log.debug(Integer.toHexString(hashCode())+"; Super returned: "+clazz);
+ }
+ return clazz;
+ }
+
+ protected Class findClass(String name)
+ throws ClassNotFoundException
+ {
+ Class clazz = null;
+ log.debug(Integer.toHexString(hashCode())+"; Asking super to findClass: "+name);
+ clazz = super.findClass(name);
+ log.debug(Integer.toHexString(hashCode())+"; Super returned: "+clazz);
+ return clazz;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEa.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEa.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEa.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,19 @@
+package org.jboss.book.jmx.ex0;
+
+import java.net.URL;
+import java.util.ArrayList;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExCCEa
+{
+ public static void main(String[] args) throws Exception
+ {
+ ArrayList array = new ArrayList();
+ array.add(new URL("file:/tmp"));
+ String url = (String) array.get(0);
+ System.out.println("URL: "+url);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEb.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEb.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEb.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,89 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.lang.reflect.Method;
+
+import org.apache.log4j.Logger;
+import org.jboss.util.ChapterExRepository;
+import org.jboss.util.Debug;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExCCEb
+{
+ public static void main(String[] args) throws Exception
+ {
+ ChapterExRepository.init(ExCCEb.class);
+
+ String chapDir = System.getProperty("chapter.dir");
+ Logger ucl0Log = Logger.getLogger("UCL0");
+ File jar0 = new File(chapDir+"/j0.jar");
+ ucl0Log.info("jar0 path: "+jar0.toString());
+ URL[] cp0 = {jar0.toURL()};
+ URLClassLoader ucl0 = new URLClassLoader(cp0);
+ Thread.currentThread().setContextClassLoader(ucl0);
+ Class ctxClass1 = ucl0.loadClass("org.jboss.book.jmx.ex0.ExCtx");
+ StringBuffer buffer = new StringBuffer("ExCtx Info");
+ Debug.displayClassInfo(ctxClass1, buffer, false);
+ ucl0Log.info(buffer.toString());
+ Object ctx0 = ctxClass1.newInstance();
+ Object value = null;
+ try
+ {
+ Class[] types = {};
+ Method getValue = ctxClass1.getMethod("getValue", types);
+ Object[] margs = {};
+ value = getValue.invoke(ctx0, margs);
+ buffer.setLength(0);
+ buffer.append("main.obj.CodeSource: ");
+ Debug.displayClassInfo(value.getClass(), buffer, false);
+ ucl0Log.info(buffer.toString());
+ }
+ catch(Exception e)
+ {
+ ucl0Log.error("Failed to invoke ExCtx.getValue", e);
+ }
+
+ File jar1 = new File(chapDir+"/j1.jar");
+ Logger ucl1Log = Logger.getLogger("UCL1");
+ ucl1Log.info("jar1 path: "+jar1.toString());
+ URL[] cp1 = {jar1.toURL()};
+ URLClassLoader ucl1 = new URLClassLoader(cp1);
+ Class ctxClass2 = ucl1.loadClass("org.jboss.book.jmx.ex0.ExCtx");
+ buffer.setLength(0);
+ buffer.append("ExCtx Info");
+ Debug.displayClassInfo(ctxClass2, buffer, false);
+ ucl1Log.info(buffer.toString());
+ Object ctx2 = ctxClass2.newInstance();
+ Thread.currentThread().setContextClassLoader(ucl1);
+ try
+ {
+ Class[] types = {Object.class};
+ Method useValue = ctxClass2.getMethod("useValue", types);
+ Object[] margs = {value};
+ useValue.invoke(ctx2, margs);
+ }
+ catch(Exception e)
+ {
+ ucl1Log.error("Failed to invoke ExCtx.useValue", e);
+ throw e;
+ }
+
+ try
+ {
+ Class[] types = {Object.class};
+ Method useValue = ctxClass2.getMethod("useValue", types);
+ Object[] margs = {value};
+ useValue.invoke(ctx2, margs);
+ }
+ catch(Exception e)
+ {
+ ucl1Log.error("Failed to invoke ExCtx.useValue", e);
+ throw e;
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEc.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEc.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCCEc.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,66 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.lang.reflect.Method;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.util.ChapterExRepository;
+import org.jboss.util.Debug;
+
+/** An example of a ClassCastException that results from classes loaded through
+ * different class loaders.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExCCEc
+{
+ public static void main(String[] args) throws Exception
+ {
+ ChapterExRepository.init(ExCCEc.class);
+
+ String chapDir = System.getProperty("chapter.dir");
+ Logger ucl0Log = Logger.getLogger("UCL0");
+ // Load ExObj from j0.jar using URLClassLoader instance 0
+ File jar0 = new File(chapDir+"/j0.jar");
+ ucl0Log.info("jar0 path: "+jar0.toString());
+ URL[] cp0 = {jar0.toURL()};
+ URLClassLoader ucl0 = new URLClassLoader(cp0);
+ Thread.currentThread().setContextClassLoader(ucl0);
+ Class objClass = ucl0.loadClass("org.jboss.book.jmx.ex0.ExObj");
+ StringBuffer buffer = new StringBuffer("ExObj Info");
+ Debug.displayClassInfo(objClass, buffer, false);
+ ucl0Log.info(buffer.toString());
+ Object value = objClass.newInstance();
+
+ // Load ExCtx from j0.jar using URLClassLoader instance 1
+ File jar1 = new File(chapDir+"/j0.jar");
+ Logger ucl1Log = Logger.getLogger("UCL1");
+ ucl1Log.info("jar1 path: "+jar1.toString());
+ URL[] cp1 = {jar1.toURL()};
+ URLClassLoader ucl1 = new URLClassLoader(cp1);
+ Thread.currentThread().setContextClassLoader(ucl1);
+ Class ctxClass2 = ucl1.loadClass("org.jboss.book.jmx.ex0.ExCtx");
+ buffer.setLength(0);
+ buffer.append("ExCtx Info");
+ Debug.displayClassInfo(ctxClass2, buffer, false);
+ ucl1Log.info(buffer.toString());
+ Object ctx2 = ctxClass2.newInstance();
+
+ try
+ {
+ // Invoke ExCtx[UCL1].useValue(value=ExObj[UCL0]) via reflection
+ Class[] types = {Object.class};
+ Method useValue = ctxClass2.getMethod("useValue", types);
+ Object[] margs = {value};
+ useValue.invoke(ctx2, margs);
+ }
+ catch(Exception e)
+ {
+ ucl1Log.error("Failed to invoke ExCtx.useValue", e);
+ throw e;
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCtx.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCtx.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExCtx.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,51 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.util.Debug;
+
+/** A classes used to demonstrate various class loading issues
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExCtx
+{
+ ExObj value;
+
+ public ExCtx() throws IOException
+ {
+ value = new ExObj();
+ Logger log = Logger.getLogger(ExCtx.class);
+ StringBuffer buffer = new StringBuffer("ctor.ExObj");
+ Debug.displayClassInfo(value.getClass(), buffer, false);
+ log.info(buffer.toString());
+ ExObj2 obj2 = value.ivar;
+ buffer.setLength(0);
+ buffer = new StringBuffer("ctor.ExObj.ivar");
+ Debug.displayClassInfo(obj2.getClass(), buffer, false);
+ log.info(buffer.toString());
+ }
+ public Object getValue()
+ {
+ return value;
+ }
+ public void useValue(Object obj) throws Exception
+ {
+ Logger log = Logger.getLogger(ExCtx.class);
+ StringBuffer buffer = new StringBuffer("useValue2.arg class");
+ Debug.displayClassInfo(obj.getClass(), buffer, false);
+ log.info(buffer.toString());
+ buffer.setLength(0);
+ buffer.append("useValue2.ExObj class");
+ Debug.displayClassInfo(ExObj.class, buffer, false);
+ log.info(buffer.toString());
+ ExObj ex = (ExObj) obj;
+ }
+ void pkgUseValue(Object obj) throws Exception
+ {
+ Logger log = Logger.getLogger(ExCtx.class);
+ log.info("In pkgUseValue");
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExIAEd.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExIAEd.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExIAEd.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,55 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.lang.reflect.Method;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.util.ChapterExRepository;
+import org.jboss.util.Debug;
+
+/** An example of IllegalAccessExceptions due to classes loaded by two class
+ * loaders.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExIAEd
+{
+ public static void main(String[] args) throws Exception
+ {
+ ChapterExRepository.init(ExIAEd.class);
+
+ String chapDir = System.getProperty("chapter.dir");
+ Logger ucl0Log = Logger.getLogger("UCL0");
+ File jar0 = new File(chapDir+"/j0.jar");
+ ucl0Log.info("jar0 path: "+jar0.toString());
+ URL[] cp0 = {jar0.toURL()};
+ URLClassLoader ucl0 = new URLClassLoader(cp0);
+ Thread.currentThread().setContextClassLoader(ucl0);
+
+ StringBuffer buffer = new StringBuffer("ExIAEd Info");
+ Debug.displayClassInfo(ExIAEd.class, buffer, false);
+ ucl0Log.info(buffer.toString());
+
+ Class ctxClass1 = ucl0.loadClass("org.jboss.book.jmx.ex0.ExCtx");
+ buffer.setLength(0);
+ buffer.append("ExCtx Info");
+ Debug.displayClassInfo(ctxClass1, buffer, false);
+ ucl0Log.info(buffer.toString());
+ Object ctx0 = ctxClass1.newInstance();
+
+ try
+ {
+ Class[] types = {Object.class};
+ Method useValue = ctxClass1.getDeclaredMethod("pkgUseValue", types);
+ Object[] margs = {null};
+ useValue.invoke(ctx0, margs);
+ }
+ catch(Exception e)
+ {
+ ucl0Log.error("Failed to invoke ExCtx.pkgUseValue", e);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExLE.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExLE.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExLE.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,61 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+import org.jboss.util.ChapterExRepository;
+import org.jboss.util.Debug;
+
+/** An example of a LinkageError due to classes being defined by more than
+ * one class loader in a non-standard class loading environment.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExLE
+{
+ public static void main(String[] args) throws Exception
+ {
+ ChapterExRepository.init(ExLE.class);
+
+ String chapDir = System.getProperty("chapter.dir");
+ Logger ucl0Log = Logger.getLogger("UCL0");
+ File jar0 = new File(chapDir+"/j0.jar");
+ ucl0Log.info("jar0 path: "+jar0.toString());
+ URL[] cp0 = {jar0.toURL()};
+ Ex0URLClassLoader ucl0 = new Ex0URLClassLoader(cp0);
+ Thread.currentThread().setContextClassLoader(ucl0);
+ Class ctxClass1 = ucl0.loadClass("org.jboss.book.jmx.ex0.ExCtx");
+ Class obj2Class1 = ucl0.loadClass("org.jboss.book.jmx.ex0.ExObj2");
+ StringBuffer buffer = new StringBuffer("ExCtx Info");
+ Debug.displayClassInfo(ctxClass1, buffer, false);
+ ucl0Log.info(buffer.toString());
+ buffer.setLength(0);
+ buffer.append("ExObj2 Info, UCL0");
+ Debug.displayClassInfo(obj2Class1, buffer, false);
+ ucl0Log.info(buffer.toString());
+
+ File jar1 = new File(chapDir+"/j1.jar");
+ Logger ucl1Log = Logger.getLogger("UCL1");
+ ucl1Log.info("jar1 path: "+jar1.toString());
+ URL[] cp1 = {jar1.toURL()};
+ Ex0URLClassLoader ucl1 = new Ex0URLClassLoader(cp1);
+ Class obj2Class2 = ucl1.loadClass("org.jboss.book.jmx.ex0.ExObj2");
+ buffer.setLength(0);
+ buffer.append("ExObj2 Info, UCL1");
+ Debug.displayClassInfo(obj2Class2, buffer, false);
+ ucl1Log.info(buffer.toString());
+
+ ucl0.setDelegate(ucl1);
+ try
+ {
+ ucl0Log.info("Try ExCtx.newInstance()");
+ Object ctx0 = ctxClass1.newInstance();
+ ucl0Log.info("ExCtx.ctor succeeded, ctx0: "+ctx0);
+ }
+ catch(Throwable e)
+ {
+ ucl0Log.error("ExCtx.ctor failed", e);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExObj implements Serializable
+{
+ public ExObj2 ivar = new ExObj2();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj2.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj2.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/ExObj2.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+package org.jboss.book.jmx.ex0;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExObj2 implements Serializable
+{
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/log4j.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/log4j.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex0/log4j.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="logs/${chapter.ex}.log" />
+ <param name="Append" value="false" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <level value ="DEBUG"/>
+ <appender-ref ref="CONSOLE" />
+ <appender-ref ref="FILE" />
+ </root>
+</log4j:configuration>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMap.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMap.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMap.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,98 @@
+package org.jboss.book.jmx.ex1;
+
+// The JNDIMap MBean implementation
+
+import java.util.HashMap;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import org.jboss.naming.NonSerializableFactory;
+
+/** An example MBean that implicitly implements the Service interface methods.
+ This is version 1 as shown in Listing 2.4.
+ */
+public class JNDIMap implements JNDIMapMBean
+{
+ private String jndiName;
+ private HashMap contextMap = new HashMap();
+ private String[] keyValuePairs;
+ private boolean started;
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName) throws NamingException
+ {
+ String oldName = this.jndiName;
+ this.jndiName = jndiName;
+ if (started)
+ {
+ unbind(oldName);
+ try
+ {
+ rebind();
+ }
+ catch (Exception e)
+ {
+ NamingException ne = new
+ NamingException("Failed to update jndiName");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ }
+
+ public String[] getInitialValues()
+ {
+ return keyValuePairs;
+ }
+
+ public void setInitialValues(String[] keyValuePairs)
+ {
+ if (keyValuePairs == null)
+ keyValuePairs = new String[0];
+ this.keyValuePairs = keyValuePairs;
+ for (int n = 0; n < keyValuePairs.length; n += 2)
+ {
+ String key = keyValuePairs[n];
+ String value = keyValuePairs[n + 1];
+ contextMap.put(key, value);
+ }
+ }
+
+ public void start() throws Exception
+ {
+ started = true;
+ rebind();
+ }
+
+ public void stop()
+ {
+ started = false;
+ unbind(jndiName);
+ }
+
+ private void rebind() throws NamingException
+ {
+ InitialContext rootCtx = new InitialContext();
+ Name fullName = rootCtx.getNameParser("").parse(jndiName);
+ System.out.println("fullName=" + fullName);
+ NonSerializableFactory.rebind(fullName, contextMap, true);
+ }
+
+ private void unbind(String jndiName)
+ {
+ try
+ {
+ InitialContext rootCtx = new InitialContext();
+ rootCtx.unbind(jndiName);
+ NonSerializableFactory.unbind(jndiName);
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMapMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMapMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/JNDIMapMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,19 @@
+package org.jboss.book.jmx.ex1;
+
+import javax.naming.NamingException;
+
+/** An example MBean that implicitly implements the Service interface methods.
+ This is version 1 as shown in Listing 2.7.
+ */
+public interface JNDIMapMBean
+{
+ public String getJndiName();
+ public void setJndiName(String jndiName) throws NamingException;
+
+ public String[] getInitialValues();
+ public void setInitialValues(String[] keyValuePairs);
+
+ public void start() throws Exception;
+ public void stop() throws Exception;
+}
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClass.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClass.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClass.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,37 @@
+package org.jboss.book.jmx.ex1;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class MyClass implements MyClassMBean
+{
+ private Integer state = null;
+ private String hidden = null;
+
+ public Integer getState()
+ {
+ return state;
+ }
+
+ public void setState(Integer s)
+ {
+ state = s;
+ }
+
+ public String getHidden()
+ {
+ return hidden;
+ }
+
+ public void setHidden(String h)
+ {
+ hidden = h;
+ }
+
+ public void reset()
+ {
+ state = null;
+ hidden = null;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClassMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClassMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MyClassMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+package org.jboss.book.jmx.ex1;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface MyClassMBean
+{
+ public Integer getState();
+ public void setState(Integer s);
+ public void reset();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclass.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclass.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclass.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,10 @@
+package org.jboss.book.jmx.ex1;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class MySubclass extends MyClass
+ implements MySubclassMBean
+{
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclassMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclassMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/MySubclassMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,10 @@
+package org.jboss.book.jmx.ex1;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface MySubclassMBean
+{
+ public void reset();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/TestMySubclass.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/TestMySubclass.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex1/TestMySubclass.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,33 @@
+package org.jboss.book.jmx.ex1;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TestMySubclass
+{
+ public static void main(String[] args) throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer("chap2.ex1.test");
+ MySubclass mbean = new MySubclass();
+ ObjectName name = new ObjectName("chap2.ex1.test:name=TestMysubclass");
+ System.out.println("Registering: "+name);
+ server.registerMBean(mbean, name);
+ MBeanInfo info = server.getMBeanInfo(name);
+ MBeanAttributeInfo[] attrInfo = info.getAttributes();
+ System.out.println("+++ Attributes("+attrInfo.length+"):");
+ for(int a = 0; a < attrInfo.length; a ++)
+ System.out.println(" "+attrInfo[a].getName());
+ MBeanOperationInfo[] opInfo = info.getOperations();
+ System.out.println("+++ Operations("+opInfo.length+"):");
+ for(int n= 0; n < opInfo.length; n ++)
+ System.out.println(" "+opInfo[n].getName());
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMap.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMap.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMap.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,73 @@
+package org.jboss.book.jmx.ex2;
+
+// The JNDIMap MBean implementation
+import java.util.HashMap;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import org.jboss.naming.NonSerializableFactory;
+
+/** An example MBean that extends the JBoss ServiceMBeanSupport class.
+This is version 2 as shown in Listing 2.5.
+*/
+public class JNDIMap extends org.jboss.system.ServiceMBeanSupport
+ implements JNDIMapMBean
+{
+ private String jndiName;
+ private HashMap contextMap = new HashMap();
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+ public void setJndiName(String jndiName) throws NamingException
+ {
+ String oldName = this.jndiName;
+ this.jndiName = jndiName;
+ if( super.getState() == STARTED )
+ {
+ unbind(oldName);
+ try
+ {
+ rebind();
+ }
+ catch(Exception e)
+ {
+ NamingException ne = new
+ NamingException("Failed to update jndiName");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ }
+
+ public void startService() throws Exception
+ {
+ rebind();
+ }
+ public void stopService()
+ {
+ unbind(jndiName);
+ }
+
+ private void rebind() throws NamingException
+ {
+ InitialContext rootCtx = new InitialContext();
+ Name fullName = rootCtx.getNameParser("").parse(jndiName);
+ log.info("fullName="+fullName);
+ NonSerializableFactory.rebind(fullName, contextMap, true);
+ }
+ private void unbind(String jndiName)
+ {
+ try
+ {
+ InitialContext rootCtx = new InitialContext();
+ rootCtx.unbind(jndiName);
+ NonSerializableFactory.unbind(jndiName);
+ }
+ catch(NamingException e)
+ {
+ log.error("Failed to unbind map", e);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMapMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMapMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/JNDIMapMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+package org.jboss.book.jmx.ex2;
+
+// The JNDIMap MBean interface
+import javax.naming.NamingException;
+
+/** An example MBean that extends the JBoss ServiceMBeanSupport class.
+This is version 2 as shown in Listing 2.8.
+*/
+public interface JNDIMapMBean extends org.jboss.system.ServiceMBean
+{
+ public String getJndiName();
+ public void setJndiName(String jndiName) throws NamingException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/jboss-service_1.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/jboss-service_1.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex2/jboss-service_1.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,6 @@
+<server>
+ <mbean code="org.jboss.book.jmx.ex2.JNDIMap" name="chap2.ex2:service=JNDIMap">
+ <attribute name="JndiName">inmemory/maps/MapTest2</attribute>
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,86 @@
+package org.jboss.book.jmx.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.ejb.FinderException;
+import javax.ejb.EJBException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ String info = "echo, arg=";
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ EchoInfoLocalHome home = (EchoInfoLocalHome) ctx.lookup("java:comp/env/ejb/EchoInfoLocalHome");
+ EchoInfoLocal bean = null;
+ try
+ {
+ bean = home.findByPrimaryKey("echo");
+ }
+ catch(FinderException e)
+ {
+ bean = home.create("echo");
+ }
+ info = bean.getInfo();
+ }
+ catch(Exception e)
+ {
+ throw new EJBException("Failed to access EchoInfo", e);
+ }
+ log.info("echo, info="+info+", arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,36 @@
+package org.jboss.book.jmx.ex3;
+
+import javax.ejb.EntityBean;
+import javax.ejb.CreateException;
+import javax.ejb.EntityContext;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public abstract class EchoInfoBean implements EntityBean
+{
+ public void setEntityContext(EntityContext ctx) { }
+ public void unsetEntityContext() { }
+ public void ejbActivate() { }
+ public void ejbPassivate() { }
+ public void ejbLoad() { }
+ public void ejbStore() { }
+ public void ejbRemove() { }
+
+ public String ejbCreate(String key) throws CreateException
+ {
+ setKey(key);
+ setInfo("echo info, arg=");
+ return null;
+ }
+
+ public void ejbPostCreate(String id)
+ {
+ }
+
+ public abstract String getKey();
+ public abstract void setKey(String key);
+ public abstract String getInfo();
+ public abstract void setInfo(String info);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocal.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocal.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocal.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+package org.jboss.book.jmx.ex3;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoInfoLocal extends EJBLocalObject
+{
+ public String getInfo();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocalHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocalHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoInfoLocalHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,15 @@
+package org.jboss.book.jmx.ex3;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoInfoLocalHome extends EJBLocalHome
+{
+ public EchoInfoLocal create(String key) throws CreateException;
+ public EchoInfoLocal findByPrimaryKey(String key) throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocal.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocal.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocal.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.jmx.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBLocalObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoLocal extends EJBLocalObject
+{
+ public String echo(String arg);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocalHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocalHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EchoLocalHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,15 @@
+package org.jboss.book.jmx.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoLocalHome extends EJBLocalHome
+{
+ public EchoLocal create()
+ throws CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EjbMBeanAdaptor.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EjbMBeanAdaptor.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/EjbMBeanAdaptor.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,318 @@
+package org.jboss.book.jmx.ex3;
+
+import java.lang.reflect.Method;
+import javax.ejb.CreateException;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InvalidAttributeValueException;
+import javax.management.JMRuntimeException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.system.ServiceMBeanSupport;
+
+/** An example of a DynamicMBean that exposes select attributes and operations
+ of an EJB as an MBean.
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public class EjbMBeanAdaptor extends ServiceMBeanSupport
+ implements DynamicMBean
+{
+ private String helloPrefix;
+ private String ejbJndiName;
+ private EchoLocalHome home;
+
+ /** These are the mbean attributes we expose
+ */
+ private MBeanAttributeInfo[] attributes = {
+ new MBeanAttributeInfo("HelloPrefix", "java.lang.String",
+ "The prefix message to append to the session echo reply",
+ true, // isReadable
+ true, // isWritable
+ false), // isIs
+ new MBeanAttributeInfo("EjbJndiName", "java.lang.String",
+ "The JNDI name of the session bean local home",
+ true, // isReadable
+ true, // isWritable
+ false) // isIs
+ };
+ /** These are the mbean operations we expose
+ */
+ private MBeanOperationInfo[] operations;
+
+
+ /** We override this method to setup our echo operation info. It could
+ also be done in a ctor.
+ */
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ throws Exception
+ {
+ log.info("preRegister notification seen");
+
+ operations = new MBeanOperationInfo[5];
+
+ Class thisClass = getClass();
+ Class[] parameterTypes = {String.class};
+ Method echoMethod = thisClass.getMethod("echo", parameterTypes);
+ String desc = "The echo op invokes the session bean echo method and"
+ + " returns its value prefixed with the helloPrefix attribute value";
+ operations[0] = new MBeanOperationInfo(desc, echoMethod);
+
+ // Add the Service interface operations from our super class
+ parameterTypes = new Class[0];
+ Method createMethod = thisClass.getMethod("create", parameterTypes);
+ operations[1] = new MBeanOperationInfo("The JBoss Service.create", createMethod);
+ Method startMethod = thisClass.getMethod("start", parameterTypes);
+ operations[2] = new MBeanOperationInfo("The JBoss Service.start", startMethod);
+ Method stopMethod = thisClass.getMethod("stop", parameterTypes);
+ operations[3] = new MBeanOperationInfo("The JBoss Service.stop", startMethod);
+ Method destroyMethod = thisClass.getMethod("destroy", parameterTypes);
+ operations[4] = new MBeanOperationInfo("The JBoss Service.destroy", startMethod);
+
+ return name;
+ }
+
+// --- Begin ServiceMBeanSupport overides
+ protected void createService() throws Exception
+ {
+ log.info("Notified of create state");
+ }
+ protected void startService() throws Exception
+ {
+ log.info("Notified of start state");
+ InitialContext ctx = new InitialContext();
+ home = (EchoLocalHome) ctx.lookup(ejbJndiName);
+ log.info("Testing Echo");
+ EchoLocal bean = home.create();
+ String echo = bean.echo("startService");
+ log.info("echo(startService) = "+echo);
+ }
+ protected void stopService()
+ {
+ log.info("Notified of stop state");
+ }
+// --- End ServiceMBeanSupport overides
+
+ public String getHelloPrefix()
+ {
+ return helloPrefix;
+ }
+ public void setHelloPrefix(String helloPrefix)
+ {
+ this.helloPrefix = helloPrefix;
+ }
+
+ public String getEjbJndiName()
+ {
+ return ejbJndiName;
+ }
+ public void setEjbJndiName(String ejbJndiName)
+ {
+ this.ejbJndiName = ejbJndiName;
+ }
+
+ public String echo(String arg)
+ throws CreateException, NamingException
+ {
+ log.info("Lookup EchoLocalHome@"+ejbJndiName);
+ EchoLocal bean = home.create();
+ String echo = helloPrefix + bean.echo(arg);
+ return echo;
+ }
+
+// --- Begin DynamicMBean interface methods
+ /** Returns the management interface that describes this dynamic resource.
+ * It is the responsibility of the implementation to make sure the
+ * description is accurate.
+ *
+ * @return the management interface descriptor.
+ */
+ public MBeanInfo getMBeanInfo()
+ {
+ String classname = getClass().getName();
+ String description = "This is an MBean that uses a session bean in the"
+ + " implementation of its echo operation.";
+ MBeanConstructorInfo[] constructors = null;
+ MBeanNotificationInfo[] notifications = null;
+ MBeanInfo mbeanInfo = new MBeanInfo(classname, description, attributes,
+ constructors, operations, notifications);
+ // Log when this is called so we know when in the lifecycle this is used
+ Throwable trace = new Throwable("getMBeanInfo trace");
+ log.info("Don't panic, just a stack trace", trace);
+ return mbeanInfo;
+ }
+
+ /** Returns the value of the attribute with the name matching the
+ * passed string.
+ *
+ * @param attribute the name of the attribute.
+ * @return the value of the attribute.
+ * @exception AttributeNotFoundException when there is no such attribute.
+ * @exception MBeanException wraps any error thrown by the resource when
+ * getting the attribute.
+ * @exception ReflectionException wraps any error invoking the resource.
+ */
+ public Object getAttribute(String attribute)
+ throws AttributeNotFoundException, MBeanException, ReflectionException
+ {
+ Object value = null;
+ if( attribute.equals("HelloPrefix") )
+ value = getHelloPrefix();
+ else if( attribute.equals("EjbJndiName") )
+ value = getEjbJndiName();
+ else
+ throw new AttributeNotFoundException("Unknown attribute("+attribute+") requested");
+ return value;
+ }
+
+ /** Returns the values of the attributes with names matching the
+ * passed string array.
+ *
+ * @param attributes the names of the attribute.
+ * @return an {@link AttributeList AttributeList} of name and value pairs.
+ */
+ public AttributeList getAttributes(String[] attributes)
+ {
+ AttributeList values = new AttributeList();
+ for(int a = 0; a < attributes.length; a ++)
+ {
+ String name = attributes[a];
+ try
+ {
+ Object value = getAttribute(name);
+ Attribute attr = new Attribute(name, value);
+ values.add(attr);
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to find attribute: "+name, e);
+ }
+ }
+ return values;
+ }
+
+ /** Sets the value of an attribute. The attribute and new value are
+ * passed in the name value pair {@link Attribute Attribute}.
+ *
+ * @see javax.management.Attribute
+ *
+ * @param attribute the name and new value of the attribute.
+ * @exception AttributeNotFoundException when there is no such attribute.
+ * @exception InvalidAttributeValueException when the new value cannot be
+ * converted to the type of the attribute.
+ * @exception MBeanException wraps any error thrown by the resource when
+ * setting the new value.
+ * @exception ReflectionException wraps any error invoking the resource.
+ */
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException
+ {
+ String name = attribute.getName();
+ if( name.equals("HelloPrefix") )
+ {
+ String value = attribute.getValue().toString();
+ setHelloPrefix(value);
+ }
+ else if( name.equals("EjbJndiName") )
+ {
+ String value = attribute.getValue().toString();
+ setEjbJndiName(value);
+ }
+ else
+ throw new AttributeNotFoundException("Unknown attribute("+name+") requested");
+ }
+
+ /** Sets the values of the attributes passed as an
+ * {@link AttributeList AttributeList} of name and new value pairs.
+ *
+ * @param attributes the name an new value pairs.
+ * @return an {@link AttributeList AttributeList} of name and value pairs
+ * that were actually set.
+ */
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ AttributeList setAttributes = new AttributeList();
+ for(int a = 0; a < attributes.size(); a ++)
+ {
+ Attribute attr = (Attribute) attributes.get(a);
+ try
+ {
+ setAttribute(attr);
+ setAttributes.add(attr);
+ }
+ catch(Exception ignore)
+ {
+ }
+ }
+ return setAttributes;
+ }
+
+ /** Invokes a resource operation.
+ *
+ * @param actionName the name of the operation to perform.
+ * @param params the parameters to pass to the operation.
+ * @param signature the signartures of the parameters.
+ * @return the result of the operation.
+ * @exception MBeanException wraps any error thrown by the resource when
+ * performing the operation.
+ * @exception ReflectionException wraps any error invoking the resource.
+ */
+ public Object invoke(String actionName, Object[] params, String[] signature)
+ throws MBeanException, ReflectionException
+ {
+ Object rtnValue = null;
+ log.info("Begin invoke, actionName="+actionName);
+ try
+ {
+ if( actionName.equals("echo") )
+ {
+ String arg = (String) params[0];
+ rtnValue = echo(arg);
+ log.info("Result: "+rtnValue);
+ }
+ else if( actionName.equals("create") )
+ {
+ super.create();
+ }
+ else if( actionName.equals("start") )
+ {
+ super.start();
+ }
+ else if( actionName.equals("stop") )
+ {
+ super.stop();
+ }
+ else if( actionName.equals("destroy") )
+ {
+ super.destroy();
+ }
+ else
+ {
+ throw new JMRuntimeException("Invalid state, don't know about op="+actionName);
+ }
+ }
+ catch(Exception e)
+ {
+ throw new ReflectionException(e, "echo failed");
+ }
+ log.info("End invoke, actionName="+actionName);
+ return rtnValue;
+ }
+
+// --- End DynamicMBean interface methods
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/application.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/application.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/application.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,9 @@
+<!DOCTYPE application PUBLIC
+ "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+ "http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+ <display-name>EJB ear</display-name>
+ <module>
+ <ejb>jmx-ex3.jar</ejb>
+ </module>
+</application>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd"
+>
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>chap2.EchoBean</ejb-name>
+ <local-home>org.jboss.book.jmx.ex3.EchoLocalHome</local-home>
+ <local>org.jboss.book.jmx.ex3.EchoLocal</local>
+ <ejb-class>org.jboss.book.jmx.ex3.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>ejb/EchoInfoLocalHome</ejb-ref-name>
+ <ejb-ref-type>Entity</ejb-ref-type>
+ <local-home>org.jboss.book.jmx.ex3.EchoInfoLocalHome</local-home>
+ <local>org.jboss.book.jmx.ex3.EchoInfoLocal</local>
+ <ejb-link>Chap2EchoInfoBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+ <entity>
+ <ejb-name>Chap2EchoInfoBean</ejb-name>
+ <local-home>org.jboss.book.jmx.ex3.EchoInfoLocalHome</local-home>
+ <local>org.jboss.book.jmx.ex3.EchoInfoLocal</local>
+ <ejb-class>org.jboss.book.jmx.ex3.EchoInfoBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.String</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>EchoInfo</abstract-schema-name>
+ <cmp-field>
+ <field-name>key</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>info</field-name>
+ </cmp-field>
+ <primkey-field>key</primkey-field>
+ </entity>
+ </enterprise-beans>
+
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-app.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-app.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-app.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,5 @@
+<jboss-app>
+ <module>
+ <service>jmx-ex3.sar</service>
+ </module>
+</jboss-app>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <mbean code="org.jboss.book.jmx.ex3.EjbMBeanAdaptor"
+ name="jboss.book:service=EjbMBeanAdaptor">
+ <attribute name="HelloPrefix">AdaptorPrefix</attribute>
+ <attribute name="EjbJndiName">local/chap2.EchoBean</attribute>
+ <depends>jboss.j2ee:service=EJB,jndiName=local/chap2.EchoBean</depends>
+ <depends>jboss.j2ee:service=EJB,jndiName=local/Chap2EchoInfoBean</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex3/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>chap2.EchoBean</ejb-name>
+ <local-jndi-name>local/chap2.EchoBean</local-jndi-name>
+ </session>
+ <session>
+ <ejb-name>Chap2EchoInfoBean</ejb-name>
+ <local-jndi-name>local/Chap2EchoInfoBean</local-jndi-name>
+ </session>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex4/JMXBrowser.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex4/JMXBrowser.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/ex4/JMXBrowser.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,69 @@
+package org.jboss.book.jmx.ex4;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+
+/**
+ * A client that demonstrates how to connect to the JMX server using
+ * the RMI adaptor.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class JMXBrowser
+{
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception
+ {
+ InitialContext ic = new InitialContext();
+ RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
+
+ // Get the MBeanInfo for the JNDIView MBean
+ ObjectName name = new ObjectName("jboss:service=JNDIView");
+ MBeanInfo info = server.getMBeanInfo(name);
+ System.out.println("JNDIView Class: " + info.getClassName());
+
+ MBeanOperationInfo[] opInfo = info.getOperations();
+ System.out.println("JNDIView Operations: ");
+ for(int o = 0; o < opInfo.length; o ++) {
+ MBeanOperationInfo op = opInfo[o];
+
+ String returnType = op.getReturnType();
+ String opName = op.getName();
+ System.out.print(" + " + returnType + " " + opName + "(");
+
+ MBeanParameterInfo[] params = op.getSignature();
+ for(int p = 0; p < params.length; p++) {
+ MBeanParameterInfo paramInfo = params[p];
+
+ String pname = paramInfo.getName();
+ String type = paramInfo.getType();
+
+ if (pname.equals(type)) {
+ System.out.print(type);
+ } else {
+ System.out.print(type + " " + name);
+ }
+
+ if (p < params.length-1) {
+ System.out.print(',');
+ }
+ }
+ System.out.println(")");
+ }
+
+ // Invoke the list(boolean) op
+ String[] sig = {"boolean"};
+ Object[] opArgs = {Boolean.TRUE};
+ Object result = server.invoke(name, "list", opArgs, sig);
+
+ System.out.println("JNDIView.list(true) output:\n"+result);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ClientInterface.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ClientInterface.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ClientInterface.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+package org.jboss.book.jmx.xmbean;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface ClientInterface
+{
+ public String[] getInitialValues();
+ public void setInitialValues(String[] keyValuePairs);
+ public Object get(Object key);
+ public void put(Object key, Object value);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/JNDIMap.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/JNDIMap.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/JNDIMap.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,166 @@
+package org.jboss.book.jmx.xmbean;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+import java.util.HashMap;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.management.Notification;
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * An XMBean variation of the JNDIMap standard MBean.
+ */
+
+public class JNDIMap
+ extends ServiceMBeanSupport
+{
+ private static final String GET_EVENT_TYPE = "org.jboss.book.jmx.xmbean.JNDIMap.get";
+ private static final String PUT_EVENT_TYPE = "org.jboss.book.jmx.xmbean.JNDIMap.put";
+
+ private String jndiName;
+ private String[] keyValuePairs = {"key0", "value0"};
+
+ private Map proxyMap = null;
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ throws NamingException
+ {
+ String oldName = this.jndiName;
+ this.jndiName = jndiName;
+
+ // we only need to act if the service has been started
+ if (super.getState() == STARTED) {
+ unbind(oldName);
+ try {
+ rebind();
+ } catch (Exception e) {
+ NamingException ne = new
+ NamingException("Failed to update jndiName");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ }
+
+ public String[] getInitialValues()
+ {
+ return keyValuePairs;
+ }
+
+ public void setInitialValues(String[] keyValuePairs)
+ {
+ if (keyValuePairs == null) {
+ keyValuePairs = new String[0];
+ }
+
+ this.keyValuePairs = keyValuePairs;
+
+ for(int n = 0; n < keyValuePairs.length; n += 2) {
+ String key = keyValuePairs[n];
+ String value = keyValuePairs[n+1];
+ put(key, value);
+ }
+ }
+
+ public void startService()
+ throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class[] interfaces = {Map.class};
+
+ proxyMap = (Map) Proxy.newProxyInstance(loader, interfaces, new ProxyMap());
+
+ log.info("Created Map proxy to handle notifications");
+
+ rebind();
+ }
+
+ public void stopService()
+ {
+ unbind(jndiName);
+ }
+
+ public Object get(Object key)
+ {
+ System.out.println("GET: " + key);
+ System.out.println("PM: " + proxyMap);
+ Object value = null;
+ if (proxyMap != null) {
+ value = proxyMap.get(key);
+ }
+ return value;
+ }
+
+ public void put(Object key, Object value)
+ {
+ System.out.println("PUT: " + key + "," + value);
+ if (proxyMap != null) {
+ proxyMap.put(key, value);
+ }
+ }
+
+
+ private void rebind()
+ throws NamingException
+ {
+ InitialContext rootCtx = new InitialContext();
+ Name fullName = rootCtx.getNameParser("").parse(jndiName);
+ log.info("fullName=" + fullName);
+ NonSerializableFactory.rebind(fullName, proxyMap, true);
+ }
+
+
+ private void unbind(String jndiName)
+ {
+ try {
+ InitialContext rootCtx = new InitialContext();
+ rootCtx.unbind(jndiName);
+ NonSerializableFactory.unbind(jndiName);
+ } catch (NamingException e) {
+ log.error("Failed to unbind map", e);
+ }
+ }
+
+
+ private void generateNotification(String type) {
+ long eventID = super.getNextNotificationSequenceNumber();
+ Notification event = new Notification(type, this, eventID);
+
+ log.info("sendNotification(event): " + event);
+
+ super.sendNotification(event);
+ }
+
+
+ public class ProxyMap
+ implements InvocationHandler
+ {
+ /** The in memory map we manage and expose through JNDI */
+ private HashMap contextMap = new HashMap();
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ Object value = method.invoke(this.contextMap, args);
+
+ if (method.getName().equals("get")) {
+ generateNotification(GET_EVENT_TYPE);
+ } else if (method.getName().equals("put")) {
+ generateNotification(PUT_EVENT_TYPE);
+ }
+
+ return value;
+ }
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ServerSecurityInterceptor.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ServerSecurityInterceptor.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/ServerSecurityInterceptor.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,64 @@
+package org.jboss.book.jmx.xmbean;
+
+import java.security.Principal;
+
+import org.jboss.logging.Logger;
+import org.jboss.mx.interceptor.AbstractInterceptor;
+import org.jboss.mx.server.Invocation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.invocation.InvocationException;
+
+/** A simple security interceptor example that restricts access to a single
+ * principal
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ServerSecurityInterceptor
+ extends AbstractInterceptor
+{
+ private static Logger log = Logger.getLogger(ServerSecurityInterceptor.class);
+ private SimplePrincipal admin = new SimplePrincipal("admin");
+
+ public String getAdminName()
+ {
+ return admin.getName();
+ }
+
+ public void setAdminName(String name)
+ {
+ admin = new SimplePrincipal(name);
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ String opName = invocation.getName();
+ log.info("invoke, opName=" + opName);
+
+ Object[] a = invocation.getArgs();
+ if (a !=null) {
+ for (int i=0; i<a.length; i++) {
+ System.out.println("arg[" + i + "]=" + a[i]);
+ }
+ }
+
+ if (opName == null || !opName.equals("invoke")) {
+ return invocation.nextInterceptor().invoke(invocation);
+ }
+
+ Object[] args = invocation.getArgs();
+ org.jboss.invocation.Invocation invokeInfo =
+ (org.jboss.invocation.Invocation) args[0];
+ Principal caller = invokeInfo.getPrincipal();
+ log.info("invoke, opName=" + opName + ", caller=" + caller);
+
+ // Only the admin caller is allowed access
+ if (caller == null || caller.equals(admin) == false) {
+ throw new SecurityException("Caller=" +
+ caller + " is not allowed access");
+ }
+
+ // Let the invocation go
+ return invocation.nextInterceptor().invoke(invocation);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean1.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean1.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean1.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,110 @@
+package org.jboss.book.jmx.xmbean;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import javax.management.Attribute;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.Notification;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.jmx.adaptor.rmi.RMINotificationListener;
+
+/**
+ * A client that demonstrates how to connect to the JMX server using
+ * the RMI adaptor.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TestXMBean1
+{
+ public static class Listener implements RMINotificationListener
+ {
+ public Listener() throws RemoteException
+ {
+ UnicastRemoteObject.exportObject(this);
+ }
+ public void handleNotification(Notification event, Object handback)
+ {
+ System.out.println("handleNotification, event: "+event);
+ }
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception
+ {
+ InitialContext ic = new InitialContext();
+ RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
+
+ // Get the MBeanInfo for the JNDIMap XMBean
+ ObjectName name = new ObjectName("chap2.xmbean:service=JNDIMap");
+ MBeanInfo info = server.getMBeanInfo(name);
+ System.out.println("JNDIMap Class: "+info.getClassName());
+ MBeanOperationInfo[] opInfo = info.getOperations();
+ System.out.println("JNDIMap Operations: ");
+ for(int o = 0; o < opInfo.length; o ++)
+ {
+ MBeanOperationInfo op = opInfo[o];
+ String returnType = op.getReturnType();
+ String opName = op.getName();
+ System.out.print(" + "+returnType+" "+opName+"(");
+ MBeanParameterInfo[] params = op.getSignature();
+ for(int p = 0; p < params.length; p ++)
+ {
+ MBeanParameterInfo paramInfo = params[p];
+ String pname = paramInfo.getName();
+ String type = paramInfo.getType();
+ if( pname.equals(type) )
+ System.out.print(type);
+ else
+ System.out.print(type+" "+name);
+ if( p < params.length-1 )
+ System.out.print(',');
+ }
+ System.out.println(")");
+ }
+
+
+ // Register as a notification listener
+ Listener listener = new Listener();
+ server.addNotificationListener(name, listener, null, null);
+
+ // Get the InitialValues attribute
+ String[] initialValues = (String[]) server.getAttribute(name, "InitialValues");
+ for(int n = 0; n < initialValues.length; n += 2)
+ {
+ String key = initialValues[n];
+ String value = initialValues[n+1];
+ System.out.println("key="+key+", value="+value);
+ }
+
+ // Invoke the put(Object, Object) op
+ String[] sig = {"java.lang.Object", "java.lang.Object"};
+ Object[] opArgs = {"key1", "value1"};
+ server.invoke(name, "put", opArgs, sig);
+ System.out.println("JNDIMap.put(key1, value1) successful");
+ sig = new String[]{"java.lang.Object"};
+ opArgs = new Object[]{"key0"};
+ Object result0 = server.invoke(name, "get", opArgs, sig);
+ System.out.println("JNDIMap.get(key0): "+result0);
+ opArgs = new Object[]{"key1"};
+ Object result1 = server.invoke(name, "get", opArgs, sig);
+ System.out.println("JNDIMap.get(key1): "+result1);
+
+ // Change the InitialValues
+ initialValues[0] = "key10";
+ initialValues[1] = "value10";
+ Attribute ivalues = new Attribute("InitialValues", initialValues);
+ server.setAttribute(name, ivalues);
+
+ // Unregister the listener.
+ server.removeNotificationListener(name, listener);
+ UnicastRemoteObject.unexportObject(listener, true);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean3.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean3.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBean3.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,63 @@
+package org.jboss.book.jmx.xmbean;
+
+import javax.naming.InitialContext;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+
+/**
+ * A client that accesses an XMBean through its RMI interface
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TestXMBean3
+{
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception
+ {
+ InitialContext ic = new InitialContext();
+ ClientInterface xmbean = (ClientInterface) ic.lookup("secure-xmbean/ClientInterface");
+
+ // This call should fail because we have not set a security context
+ try {
+ String[] tmp = xmbean.getInitialValues();
+ throw new IllegalStateException("Was able to call getInitialValues");
+ } catch (Exception e) {
+ System.out.println("Called to getInitialValues failed as expected: "
+ + e.getMessage());
+ }
+
+ // Set a security context using the SecurityAssociation
+ SecurityAssociation.setPrincipal(new SimplePrincipal("admin"));
+
+ // Get the InitialValues attribute
+ String[] initialValues = xmbean.getInitialValues();
+ for(int n = 0; n < initialValues.length; n += 2) {
+ String key = initialValues[n];
+ String value = initialValues[n+1];
+ System.out.println("key="+key+", value="+value);
+ }
+
+ // Invoke the put(Object, Object) op
+ xmbean.put("key1", "value1");
+ System.out.println("JNDIMap.put(key1, value1) successful");
+ Object result0 = xmbean.get("key0");
+ System.out.println("JNDIMap.get(key0): "+result0);
+ Object result1 = xmbean.get("key1");
+ System.out.println("JNDIMap.get(key1): "+result1);
+
+ // Change the InitialValues
+ initialValues[0] += ".1";
+ initialValues[1] += ".2";
+ xmbean.setInitialValues(initialValues);
+
+ initialValues = xmbean.getInitialValues();
+ for(int n = 0; n < initialValues.length; n += 2) {
+ String key = initialValues[n];
+ String value = initialValues[n+1];
+ System.out.println("key="+key+", value="+value);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBeanRestart.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBeanRestart.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/TestXMBeanRestart.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,47 @@
+
+package org.jboss.book.jmx.xmbean;
+
+import javax.management.Attribute;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+
+/** A client that demonstrates the persistence of the xmbean attributes. Every
+ time it it run it looks up the InitialValues attribute, prints it out
+ and then adds a new key/value to the list.
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public class TestXMBeanRestart
+{
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Exception
+ {
+ InitialContext ic = new InitialContext();
+ RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
+
+ // Get the InitialValues attribute
+ ObjectName name = new ObjectName("chap2.xmbean:service=JNDIMap");
+ String[] initialValues = (String[]) server.getAttribute(name, "InitialValues");
+ System.out.println("InitialValues.length="+initialValues.length);
+ int length = initialValues.length;
+ for(int n = 0; n < length; n += 2)
+ {
+ String key = initialValues[n];
+ String value = initialValues[n+1];
+ System.out.println("key="+key+", value="+value);
+ }
+ // Add a new key/value pair
+ String[] newInitialValues = new String[length+2];
+ System.arraycopy(initialValues, 0, newInitialValues, 0, length);
+ newInitialValues[length] = "key"+(length/2+1);
+ newInitialValues[length+1] = "value"+(length/2+1);
+
+ Attribute ivalues = new Attribute("InitialValues", newInitialValues);
+ server.setAttribute(name, ivalues);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<!DOCTYPE server PUBLIC
+ "-//JBoss//DTD MBean Service 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-service_3_2.dtd">
+
+<server>
+ <mbean code="org.jboss.book.jmx.xmbean.JNDIMap" name="chap2.xmbean:service=JNDIMap"
+ xmbean-dd="META-INF/jndimap-xmbean.xml">
+ <attribute name="JndiName">inmemory/maps/MapTest</attribute>
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service2.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service2.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service2.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<!DOCTYPE server PUBLIC
+ "-//JBoss//DTD MBean Service 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-service_3_2.dtd"
+>
+
+<server>
+ <mbean code="org.jboss.book.jmx.xmbean.JNDIMap" name="chap2.xmbean:service=JNDIMap"
+ xmbean-dd="META-INF/jndimap-xmbean.xml">
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service3.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service3.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jboss-service3.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--DOCTYPE server
+ PUBLIC "-//JBoss//DTD MBean Service 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-service_3_2.dtd"
+
+This instance goes beyond the jboss-service_3_2.dtd model
+due to its use of the embedded <interceptors> element in the
+ClientInterceptors attribute of the JRMPProxyFactory config.
+-->
+
+<server>
+ <mbean code="org.jboss.book.jmx.xmbean.InvokeJNDIMap"
+ name="chap2.xmbean:service=JNDIMap,version=3"
+ xmbean-dd="META-INF/jndimap-xmbean3.xml">
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+
+ <!-- The JRMP invoker proxy configuration for the naming service -->
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
+ name="jboss.test:service=proxyFactory,type=jrmp,target=JNDIMap">
+ <!-- Use the standard JRMPInvoker from conf/jboss-service.xml -->
+ <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
+ <attribute name="TargetName">chap2.xmbean:service=JNDIMap,version=3</attribute>
+ <attribute name="JndiName">secure-xmbean/ClientInterface</attribute>
+ <attribute name="ExportedInterface">org.jboss.book.jmx.xmbean.ClientInterface</attribute>
+
+ <!-- <attribute name="InvokeTargetMethod">true</attribute> -->
+
+ <attribute name="ClientInterceptors">
+ <iterceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </iterceptors>
+ </attribute>
+ <depends>jboss:service=invoker,type=jrmp</depends>
+ <depends>chap2.xmbean:service=JNDIMap,version=3</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean1.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean1.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean1.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbean PUBLIC
+ "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
+
+<mbean>
+ <description>The JNDIMap XMBean Example Version 1</description>
+
+ <descriptors>
+ <persistence persistPolicy="Never"
+ persistPeriod="10"
+ persistLocation="data/JNDIMap.data"
+ persistName="JNDIMap"/>
+ <currencyTimeLimit value="10"/>
+ <state-action-on-update value="keep-running"/>
+ </descriptors>
+
+ <class>org.jboss.test.jmx.xmbean.JNDIMap</class>
+
+ <constructor>
+ <description>The default constructor</description>
+ <name>JNDIMap</name>
+ </constructor>
+
+ <!-- Attributes -->
+ <attribute access="read-write" getMethod="getJndiName" setMethod="setJndiName">
+ <description>The location in JNDI where the Map we manage will be bound</description>
+ <name>JndiName</name>
+ <type>java.lang.String</type>
+ <descriptors>
+ <default value="inmemory/maps/MapTest" />
+ </descriptors>
+ </attribute>
+ <attribute access="read-write" getMethod="getInitialValues" setMethod="setInitialValues">
+ <description>The array of initial values that will be placed into
+ the map associated with the service. The array is a collection of
+ key,value pairs with elements[0,2,4,...2n] being the keys and
+ elements [1,3,5,...,2n+1] the associated values</description>
+ <name>InitialValues</name>
+ <type>[Ljava.lang.String;</type>
+ <descriptors>
+ <default value="key0,value0" />
+ </descriptors>
+ </attribute>
+
+ <!-- Operations -->
+ <operation>
+ <description>The start lifecycle operation</description>
+ <name>start</name>
+ </operation>
+ <operation>
+ <description>The stop lifecycle operation</description>
+ <name>stop</name>
+ </operation>
+ <operation impact="ACTION">
+ <description>Put a value into the nap</description>
+ <name>put</name>
+ <parameter>
+ <description>The key the value will be store under</description>
+ <name>key</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <parameter>
+ <description>The value to place into the map</description>
+ <name>value</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ </operation>
+ <operation impact="INFO">
+ <description>Get a value from the map</description>
+ <name>get</name>
+ <parameter>
+ <description>The key to lookup in the map</description>
+ <name>get</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <return-type>java.lang.Object</return-type>
+ </operation>
+
+ <!-- Notifications -->
+ <notification>
+ <description>The notification sent whenever a value is get into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.get</notification-type>
+ </notification>
+ <notification>
+ <description>The notification sent whenever a value is put into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.put</notification-type>
+ </notification>
+</mbean>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean2.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean2.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean2.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbean PUBLIC
+ "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
+
+<mbean>
+ <description>The JNDIMap XMBean Example Version 2</description>
+
+ <descriptors>
+ <persistence persistPolicy="OnUpdate"
+ persistPeriod="10"
+ persistLocation="${jboss.server.data.dir}"
+ persistName="JNDIMap.ser"/>
+ <currencyTimeLimit value="10"/>
+ <state-action-on-update value="keep-running"/>
+ <persistence-manager value="org.jboss.mx.persistence.ObjectStreamPersistenceManager" />
+ </descriptors>
+
+ <class>org.jboss.test.jmx.xmbean.JNDIMap</class>
+
+ <constructor>
+ <description>The default constructor</description>
+ <name>JNDIMap</name>
+ </constructor>
+
+ <!-- Attributes -->
+ <attribute access="read-write" getMethod="getJndiName" setMethod="setJndiName">
+ <description>The location in JNDI where the Map we manage will be bound</description>
+ <name>JndiName</name>
+ <type>java.lang.String</type>
+ <descriptors>
+ <value value="inmemory/maps/MapTest" />
+ </descriptors>
+ </attribute>
+ <attribute access="read-write" getMethod="getInitialValues" setMethod="setInitialValues">
+ <description>The array of initial values that will be placed into
+ the map associated with the service. The array is a collection of
+ key,value pairs with elements[0,2,4,...2n] being the keys and
+ elements [1,3,5,...,2n+1] the associated values</description>
+ <name>InitialValues</name>
+ <type>[Ljava.lang.String;</type>
+ <descriptors>
+ <default value="key0,value0" />
+ </descriptors>
+ </attribute>
+
+ <!-- Operations -->
+ <operation>
+ <description>The start lifecycle operation</description>
+ <name>start</name>
+ </operation>
+ <operation>
+ <description>The stop lifecycle operation</description>
+ <name>stop</name>
+ </operation>
+ <operation impact="ACTION">
+ <description>Put a value into the nap</description>
+ <name>put</name>
+ <parameter>
+ <description>The key the value will be store under</description>
+ <name>key</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <parameter>
+ <description>The value to place into the map</description>
+ <name>value</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ </operation>
+ <operation impact="INFO">
+ <description>Get a value from the map</description>
+ <name>get</name>
+ <parameter>
+ <description>The key to lookup in the map</description>
+ <name>get</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <return-type>java.lang.Object</return-type>
+ </operation>
+
+ <!-- Notifications -->
+ <notification>
+ <description>The notification sent whenever a value is get into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.get</notification-type>
+ </notification>
+ <notification>
+ <description>The notification sent whenever a value is put into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.put</notification-type>
+ </notification>
+</mbean>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean3.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean3.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/jmx/xmbean/jndimap-xmbean3.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbean PUBLIC
+ "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd"
+[
+ <!ATTLIST interceptor adminName CDATA #IMPLIED>
+]
+>
+
+<mbean>
+ <description>The JNDIMap XMBean Example Version 3</description>
+
+ <descriptors>
+
+ <interceptors>
+ <interceptor code="org.jboss.book.jmx.xmbean.ServerSecurityInterceptor"
+ adminName="admin"/>
+ <interceptor code="org.jboss.book.jmx.xmbean.InvokerInterceptor" />
+
+ <interceptor code="org.jboss.mx.interceptor.PersistenceInterceptor2" />
+ <interceptor code="org.jboss.mx.interceptor.ModelMBeanInterceptor" />
+ <interceptor code="org.jboss.mx.interceptor.ObjectReferenceInterceptor" />
+
+ </interceptors>
+
+ <persistence persistPolicy="Never" />
+ <currencyTimeLimit value="10" />
+ </descriptors>
+
+ <class>org.jboss.test.jmx.xmbean.InvokeJNDIMap</class>
+
+ <constructor>
+ <description>The default constructor</description>
+ <name>JNDIMap</name>
+ </constructor>
+
+ <!-- Attributes -->
+ <attribute access="read-write" getMethod="getJndiName" setMethod="setJndiName">
+ <description>The location in JNDI where the Map we manage will be bound</description>
+ <name>JndiName</name>
+ <type>java.lang.String</type>
+ <descriptors>
+ <value value="inmemory/maps/MapTest" />
+ </descriptors>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getInitialValues" setMethod="setInitialValues">
+ <description>The array of initial values that will be placed into
+ the map associated with the service. The array is a collection of
+ key,value pairs with elements[0,2,4,...2n] being the keys and
+ elements [1,3,5,...,2n+1] the associated values</description>
+ <name>InitialValues</name>
+ <type>[Ljava.lang.String;</type>
+ <descriptors>
+ <value value="key0,value0" />
+ </descriptors>
+ </attribute>
+
+ <!-- Operations -->
+ <operation>
+ <description>The start lifecycle operation</description>
+ <name>start</name>
+ </operation>
+ <operation>
+ <description>The stop lifecycle operation</description>
+ <name>stop</name>
+ </operation>
+ <operation impact="ACTION">
+ <description>Put a value into the nap</description>
+ <name>put</name>
+ <parameter>
+ <description>The key the value will be store under</description>
+ <name>key</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <parameter>
+ <description>The value to place into the map</description>
+ <name>value</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ </operation>
+ <operation impact="INFO">
+ <description>Get a value from the map</description>
+ <name>get</name>
+ <parameter>
+ <description>The key to lookup in the map</description>
+ <name>get</name>
+ <type>java.lang.Object</type>
+ </parameter>
+ <return-type>java.lang.Object</return-type>
+ </operation>
+
+ <operation impact="INFO">
+ <description>The detached invoker invoke(Invocation) entry point</description>
+ <name>invoke</name>
+ <parameter>
+ <description>The Invocation representation</description>
+ <name>invocation</name>
+ <type>org.jboss.invocation.Invocation</type>
+ </parameter>
+ <return-type>java.lang.Object</return-type>
+ </operation>
+
+ <!-- Notifications -->
+ <notification>
+ <description>The notification sent whenever a value is get into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.get</notification-type>
+ </notification>
+ <notification>
+ <description>The notification sent whenever a value is put into the map
+ managed by the service</description>
+ <name>javax.management.Notification</name>
+ <notification-type>org.jboss.book.jmx.xmbean.JNDIMap.put</notification-type>
+ </notification>
+</mbean>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/ExSchedulable.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/ExSchedulable.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/ExSchedulable.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,32 @@
+package org.jboss.book.misc.ex2;
+
+import java.util.Date;
+import org.jboss.varia.scheduler.Schedulable;
+
+import org.apache.log4j.Logger;
+
+/** A simple Schedulable example.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExSchedulable implements Schedulable
+{
+ private static final Logger log = Logger.getLogger(ExSchedulable.class);
+
+ private String name;
+ private long value;
+
+ public ExSchedulable(String name, long value)
+ {
+ this.name = name;
+ this.value = value;
+ log.info("ctor, name: " + name + ", value: " + value);
+ }
+
+ public void perform(Date now, long remainingRepetitions)
+ {
+ log.info("perform, now: " + now +
+ ", remainingRepetitions: " + remainingRepetitions +
+ ", name: " + name + ", value: " + value);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/misc/ex2/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.varia.scheduler.Scheduler"
+ name="jboss.docs:service=Scheduler">
+ <attribute name="StartAtStartup">true</attribute>
+ <attribute name="SchedulableClass">org.jboss.book.misc.ex2.ExSchedulable</attribute>
+ <attribute name="SchedulableArguments">TheName,123456789</attribute>
+ <attribute name="SchedulableArgumentTypes">java.lang.String,long</attribute>
+ <attribute name="InitialStartDate">NOW</attribute>
+ <attribute name="SchedulePeriod">60000</attribute>
+ <attribute name="InitialRepetitions">-1</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.security.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,61 @@
+package org.jboss.book.security.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.debug("echo, arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex1;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoSecurityProxy.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoSecurityProxy.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/EchoSecurityProxy.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,73 @@
+package org.jboss.book.security.ex1;
+
+import java.lang.reflect.Method;
+import javax.ejb.EJBContext;
+
+import org.apache.log4j.Category;
+
+import org.jboss.security.SecurityProxy;
+
+/**
+ * A simple example of a custom SecurityProxy implementation that
+ * demonstrates method argument based security checks.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class EchoSecurityProxy
+ implements SecurityProxy
+{
+ Category log = Category.getInstance(EchoSecurityProxy.class);
+ Method echo;
+
+ public void init(Class beanHome, Class beanRemote,
+ Object securityMgr)
+ throws InstantiationException
+ {
+ init(beanHome, beanRemote, null, null, securityMgr);
+ }
+
+ public void init(Class beanHome, Class beanRemote,
+ Class beanLocalHome, Class beanLocal, Object securityMgr)
+ throws InstantiationException
+ {
+ log.debug("init, beanHome=" + beanHome + ", beanRemote=" + beanRemote +
+ ", beanLocalhome=" + beanLocalHome + ", beanLocal=" + beanLocal +
+ ", securityMgr=" + securityMgr);
+ // Get the echo method for equality testing in invoke
+ try {
+ Class[] params = {String.class};
+ echo = beanRemote.getDeclaredMethod("echo", params);
+ } catch(Exception e) {
+ String msg = "Failed to find an echo(String) method";
+ log.error(msg, e);
+ throw new InstantiationException(msg);
+ }
+ }
+
+ public void setEJBContext(EJBContext ctx)
+ {
+ log.debug("setEJBContext, ctx=" + ctx);
+ }
+
+ public void invokeHome(Method m, Object[] args)
+ throws SecurityException
+ {
+ // We don't validate access to home methods
+ }
+
+ public void invoke(Method m, Object[] args, Object bean)
+ throws SecurityException
+ {
+ log.debug("invoke, m=" + m);
+ // Check for the echo method
+ if (m.equals(echo)) {
+ // Validate that the msg arg is not 4 letter word
+ String arg = (String) args[0];
+ if (arg == null || arg.length() == 4) {
+ throw new SecurityException("No 4 letter words");
+ }
+ // We are not responsible for doing the invoke
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,27 @@
+package org.jboss.book.security.ex1;
+
+import javax.naming.InitialContext;
+import org.apache.log4j.Logger;
+
+/**
+; * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[])
+ throws Exception
+ {
+ Logger log = Logger.getLogger("ExClient");
+ log.info("Looking up EchoBean");
+
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("security.EchoBean");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+
+ log.info("Created Echo");
+ log.info("Echo.echo('Hello') = " + echo.echo("Hello"));
+ log.info("Echo.echo('Four') = " + echo.echo("Four"));
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean</ejb-name>
+ <home>org.jboss.book.security.ex1.EchoHome</home>
+ <remote>org.jboss.book.security.ex1.Echo</remote>
+ <ejb-class>org.jboss.book.security.ex1.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <method-permission>
+ <unchecked/>
+ <method>
+ <ejb-name>EchoBean</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <!-- The custom JAAS login configuration that installs
+ a Configuration capable of dynamically updating the
+ config settings
+ -->
+ <mbean code="org.jboss.book.security.service.SecurityConfig"
+ name="jboss.docs.security:service=LoginConfig-EX1">
+ <attribute name="AuthConfig">META-INF/login-config.xml</attribute>
+ <attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<jboss>
+ <security-domain>java:/jaas/security-ex1</security-domain>
+
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean</ejb-name>
+ <jndi-name>security.EchoBean</jndi-name>
+ <security-proxy>org.jboss.book.security.ex1.EchoSecurityProxy</security-proxy>
+ </session>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/roles.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/roles.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/roles.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=Echo,TheDuke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/users.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/users.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex1/users.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=theduke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex10/TimedCachePolicy.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex10/TimedCachePolicy.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex10/TimedCachePolicy.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex10;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TimedCachePolicy
+{
+
+ /** Creates new TimedCachePolicy */
+ public TimedCachePolicy()
+ {
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.security.ex2;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,61 @@
+package org.jboss.book.security.ex2;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.debug("echo, arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex2;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,33 @@
+package org.jboss.book.security.ex2;
+
+import javax.naming.InitialContext;
+import javax.security.auth.login.LoginContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.security.auth.callback.UsernamePasswordHandler;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ Logger log = Logger.getLogger("ExClient");
+ log.info("Login with username="+args[0]+", password="+args[1]);
+ UsernamePasswordHandler handler = new UsernamePasswordHandler(args[0], args[1].toCharArray());
+ LoginContext lc = new LoginContext("ExClient", handler);
+ lc.login();
+
+ log.info("Looking up EchoBean2");
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean2");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+ log.info("Created Echo");
+ log.info("Echo.echo('Hello') = "+echo.echo("Hello"));
+ lc.logout();
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/JndiUserAndPass.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/JndiUserAndPass.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/JndiUserAndPass.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,86 @@
+package org.jboss.book.security.ex2;
+
+import java.security.acl.Group;
+import java.util.Map;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
+
+/** An example custom login module that obtains passwords and roles for a user
+from a JNDI lookup.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class JndiUserAndPass extends UsernamePasswordLoginModule
+{
+ /** The JNDI name to the context that handles the password/<username> lookup */
+ private String userPathPrefix;
+ /** The JNDI name to the context that handles the roles/<username> lookup */
+ private String rolesPathPrefix;
+
+ /** Override to obtain the userPathPrefix and rolesPathPrefix options.
+ */
+ public void initialize(Subject subject, CallbackHandler callbackHandler,
+ Map sharedState, Map options)
+ {
+ super.initialize(subject, callbackHandler, sharedState, options);
+ userPathPrefix = (String) options.get("userPathPrefix");
+ rolesPathPrefix = (String) options.get("rolesPathPrefix");
+ }
+
+ /** Get the roles the current user belongs to by querying the
+ rolesPathPrefix + '/' + super.getUsername() JNDI location.
+ */
+ protected Group[] getRoleSets() throws LoginException
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ String rolesPath = rolesPathPrefix + '/' + super.getUsername();
+ String[] roles = (String[]) ctx.lookup(rolesPath);
+ Group[] groups = {new SimpleGroup("Roles")};
+ log.info("Getting roles for user="+super.getUsername());
+ for(int r = 0; r < roles.length; r ++)
+ {
+ SimplePrincipal role = new SimplePrincipal(roles[r]);
+ log.info("Found role="+roles[r]);
+ groups[0].addMember(role);
+ }
+ return groups;
+ }
+ catch(NamingException e)
+ {
+ log.error("Failed to obtain groups for user="+super.getUsername(), e);
+ throw new LoginException(e.toString(true));
+ }
+ }
+
+ /** Get the password of the current user by querying the
+ userPathPrefix + '/' + super.getUsername() JNDI location.
+ */
+ protected String getUsersPassword() throws LoginException
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ String userPath = userPathPrefix + '/' + super.getUsername();
+ log.info("Getting password for user="+super.getUsername());
+ String passwd = (String) ctx.lookup(userPath);
+ log.info("Found password="+passwd);
+ return passwd;
+ }
+ catch(NamingException e)
+ {
+ log.error("Failed to obtain password for user="+super.getUsername(), e);
+ throw new LoginException(e.toString(true));
+ }
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean2</ejb-name>
+ <home>org.jboss.book.security.ex2.EchoHome</home>
+ <remote>org.jboss.book.security.ex2.Echo</remote>
+ <ejb-class>org.jboss.book.security.ex2.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <method-permission>
+ <role-name>Echo</role-name>
+ <method>
+ <ejb-name>EchoBean2</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <mbean code="org.jboss.book.security.ex2.service.JndiStore"
+ name="jboss.docs.security:service=JndiStore"/>
+
+ <!-- The custom JAAS login configuration that installs
+ a Configuration capable of dynamically updating the
+ config settings
+ -->
+ <mbean code="org.jboss.book.security.service.SecurityConfig"
+ name="jboss.docs.security:service=LoginConfig-EX2">
+ <attribute name="AuthConfig">META-INF/login-config.xml</attribute>
+ <attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<jboss>
+ <security-domain>java:/jaas/security-ex2</security-domain>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStore.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStore.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStore.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,108 @@
+package org.jboss.book.security.ex2.service;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.naming.Util;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class JndiStore
+ implements JndiStoreMBean, InvocationHandler, ObjectFactory
+{
+ private static Logger log = Logger.getLogger(JndiStore.class);
+
+ private static String password = "theduke";
+ private static String[] roles = {"TheDuke", "Echo"};
+ private static NameParser parser;
+
+ /** Creates a new instance of JndiStore */
+ public JndiStore()
+ {
+ }
+
+ public void start() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ parser = ctx.getNameParser("");
+
+ /* Create a mapping from the security/store context to a this ObjectFactory
+ so that any lookup against security/store/password/username our password
+ and security/store/roles/username returns our roles.
+ */
+ RefAddr refAddr = new StringRefAddr("nns", "JndiStore");
+ String factoryName = JndiStore.class.getName();
+ Reference ref = new Reference("javax.naming.Context", refAddr, factoryName, null);
+
+ Util.rebind(ctx, "security/store", ref);
+ log.info("Start, bound security/store");
+ }
+ public void stop()
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ ctx.unbind("security/store");
+ log.info("Stop, unbound security/store");
+ }
+ catch(NamingException e)
+ {
+ }
+ }
+
+ /** Object factory implementation. This method returns a Context proxy
+ that is only able to handle a lookup operation for an atomic name of
+ a security domain.
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment)
+ throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class[] interfaces = {Context.class};
+ Context ctx = (Context) Proxy.newProxyInstance(loader, interfaces, this);
+ return ctx;
+ }
+
+ /** This is the InvocationHandler callback for the Context interface that
+ was created by out getObjectInstance() method. We handle the security/store
+ context lookups here.
+ */
+ public Object invoke(Object obj, Method method, Object[] args) throws Throwable
+ {
+ String methodName = method.getName();
+ if( methodName.equals("toString") == true )
+ return "security/store Context proxy";
+ if( methodName.equals("lookup") == false )
+ throw new OperationNotSupportedException("Only lookup is supported, op="+method);
+
+ Name name = null;
+ if( args[0] instanceof String )
+ name = parser.parse((String) args[0]);
+ else
+ name = (Name) args[0];
+ String type = name.toString();
+ log.info("lookup, name="+name);
+ if( type.startsWith("password") == true )
+ return password;
+ if( type.startsWith("roles") == true )
+ return roles;
+ throw new InvalidNameException("The request type must be password or roles, type="+type);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStoreMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStoreMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex2/service/JndiStoreMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+package org.jboss.book.security.ex2.service;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface JndiStoreMBean
+{
+ public void start() throws Exception;
+ public void stop();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.security.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,64 @@
+package org.jboss.book.security.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.debug("echo, arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex3;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,54 @@
+package org.jboss.book.security.ex3;
+
+import java.rmi.RemoteException;
+import javax.naming.InitialContext;
+import javax.security.auth.login.LoginContext;
+
+import org.jboss.security.auth.callback.UsernamePasswordHandler;
+import org.jboss.util.ChapterExRepository;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ // Setup the example log4j repository
+ ChapterExRepository.init(ExClient.class);
+
+ // Login using SRP
+ System.out.println("Logging in using the 'srp' configuration");
+ String username = args[0];
+ char[] password = args[1].toCharArray();
+ UsernamePasswordHandler handler = new UsernamePasswordHandler(username, password);
+ LoginContext lc = new LoginContext("srp", handler);
+ lc.login();
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean3");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+ System.out.println("Created Echo");
+ System.out.println("Echo.echo()#1 = "+echo.echo("This is call 1"));
+ Thread.currentThread().sleep(15*1000);
+ /* This will fail due to a SRP cache timeout if the JaasSecurityManager
+ cache timeout is also set to the same values.
+ */
+ try
+ {
+ System.out.println("Echo.echo()#2 = "+echo.echo("This is call 2"));
+ }
+ catch(Throwable e)
+ {
+ while( e instanceof RemoteException )
+ {
+ RemoteException re = (RemoteException) e;
+ e = re.detail;
+ }
+ System.out.println("Echo.echo()#2 failed with exception: "+e.getMessage());
+ }
+ lc.logout();
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClientSetup.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClientSetup.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ExClientSetup.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,34 @@
+package org.jboss.book.security.ex3;
+
+import java.net.InetAddress;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.login.LoginContext;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+
+/** A program that creates an account for username=jduke, password=theduke
+ using the SRPVerifierStoreService MBean addUser operation.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class ExClientSetup
+{
+ public static void main(String args[]) throws Exception
+ {
+ String username = args[0];
+ String password = args[1];
+ System.out.println("Accessing the Security:service=SRPVerifierStore MBean server");
+ String serverName = InetAddress.getLocalHost().getHostName();
+ String connectorName = "jmx:" +serverName+ ":rmi";
+ RMIAdaptor server = (RMIAdaptor) new InitialContext().lookup(connectorName);
+ ObjectName srpStore = new ObjectName("Security:service=SRPVerifierStore");
+ System.out.println("Creating username="+username+", password="+password);
+ Object[] params = {"jduke", "theduke"};
+ String[] signature = {"java.lang.String", "java.lang.String"};
+ server.invoke(srpStore, "addUser", params, signature);
+ System.out.println("User jduke added");
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean3</ejb-name>
+ <home>org.jboss.book.security.ex3.EchoHome</home>
+ <remote>org.jboss.book.security.ex3.Echo</remote>
+ <ejb-class>org.jboss.book.security.ex3.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <security-role>
+ <role-name>Echo</role-name>
+ </security-role>
+
+ <method-permission>
+ <role-name>Echo</role-name>
+
+ <method>
+ <ejb-name>EchoBean3</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <!-- The custom JAAS login configuration that installs
+ a Configuration capable of dynamically updating the
+ config settings
+ -->
+ <mbean code="org.jboss.book.security.service.SecurityConfig"
+ name="jboss.docs.security:service=LoginConfig-EX3">
+ <attribute name="AuthConfig">META-INF/login-config.xml</attribute>
+ <attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+
+ <!-- The SRP service that provides the SRP RMI server and server side
+ authentication cache -->
+ <mbean code="org.jboss.security.srp.SRPService"
+ name="jboss.docs.security:service=SRPService">
+ <attribute name="VerifierSourceJndiName">srp-test/security-ex3</attribute>
+ <attribute name="JndiName">srp-test/SRPServerInterface</attribute>
+ <attribute name="AuthenticationCacheJndiName">srp-test/AuthenticationCache</attribute>
+ <attribute name="AuthenticationCacheTimeout">10</attribute>
+ <attribute name="AuthenticationCacheResolution">5</attribute>
+ <attribute name="ServerPort">0</attribute>
+ <depends>jboss.docs.security:service=PropertiesVerifierStore</depends>
+ </mbean>
+
+ <!-- The SRP store handler service that provides the user password verifier
+ information -->
+ <mbean code="org.jboss.book.security.ex3.service.PropertiesVerifierStore"
+ name="jboss.docs.security:service=PropertiesVerifierStore">
+ <attribute name="JndiName">srp-test/security-ex3</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<jboss>
+ <security-domain>java:/jaas/security-ex3</security-domain>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/log4j.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/log4j.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/log4j.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="logs/ex3-trace.log" />
+ <param name="Append" value="false" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.security" additivity="false">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ <appender-ref ref="FILE"/>
+ </category>
+ <category name="org.jboss.security.auth.login.XMLLoginConfigImpl" additivity="false">
+ <priority value="INFO" />
+ <appender-ref ref="FILE"/>
+ </category>
+
+ <root>
+ <level value ="DEBUG"/>
+ <appender-ref ref="CONSOLE" />
+ <appender-ref ref="FILE" />
+ </root>
+</log4j:configuration>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/roles.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/roles.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/roles.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=Echo,TheDuke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStore.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStore.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStore.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,139 @@
+package org.jboss.book.security.ex3.service;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.net.URL;
+import java.security.KeyException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.security.Util;
+import org.jboss.security.srp.SRPConf;
+import org.jboss.security.srp.SRPVerifierStore;
+import org.jboss.security.srp.SRPVerifierStore.VerifierInfo;
+import org.jboss.system.ServiceMBeanSupport;
+
+/** The PropertiesVerifierStore service is a SRPVerifierStore implementation
+ that obtains the username and password info from a properties file and then
+ creates an in memory SRPVerifierStore.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public class PropertiesVerifierStore extends ServiceMBeanSupport
+ implements PropertiesVerifierStoreMBean, SRPVerifierStore
+{
+ private String jndiName = "srp/DefaultVerifierSource";
+ private HashMap storeMap = new HashMap();
+ private Thread addUserThread;
+
+ /** Creates a new instance of PropertiesVerifierStore */
+ public PropertiesVerifierStore()
+ {
+ }
+
+ /** Get the jndi name for the SRPVerifierSource implementation binding.
+ */
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+ /** set the jndi name for the SRPVerifierSource implementation binding.
+ */
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ protected void startService() throws Exception
+ {
+ // Make sure the security utility class is initialized
+ Util.init();
+
+ // Find the users.properties file
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ URL users = loader.getResource("users.properties");
+ if( users == null )
+ throw new FileNotFoundException("Failed to find users.properties resource");
+ log.info("Using users.properties: "+users);
+ InputStream is = users.openStream();
+ final Properties userPasswords = new Properties();
+ userPasswords.load(is);
+ addUserThread = new Thread("AddUsers")
+ {
+ public void run()
+ {
+ Iterator keys = userPasswords.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ String username = (String) keys.next();
+ char[] password = userPasswords.getProperty(username).toCharArray();
+ addUser(username, password);
+ }
+ }
+ };
+ addUserThread.start();
+
+ // Bind a reference to the SRPVerifierStore using NonSerializableFactory
+ InitialContext ctx = new InitialContext();
+ Name name = ctx.getNameParser("").parse(jndiName);
+ NonSerializableFactory.rebind(name, this, true);
+ log.debug("Bound SRPVerifierStore at "+jndiName);
+ }
+ protected void stopService() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ NonSerializableFactory.unbind(jndiName);
+ ctx.unbind(jndiName);
+ log.debug("Unbound SRPVerifierStore at "+jndiName);
+ }
+
+ public VerifierInfo getUserVerifier(String username) throws KeyException, IOException
+ {
+ if( addUserThread != null )
+ {
+ try
+ {
+ addUserThread.join();
+ addUserThread = null;
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ VerifierInfo info = (VerifierInfo) storeMap.get(username);
+ return info;
+ }
+ public void setUserVerifier(String username, VerifierInfo info) throws IOException
+ {
+ throw new IOException("PropertiesVerifierStore is read only");
+ }
+
+ public void verifyUserChallenge(String username, Object challenge)
+ {
+ }
+
+ private void addUser(String username, char[] password)
+ {
+ VerifierInfo info = new VerifierInfo();
+ info.username = username;
+ // Create a random salt
+ long r = Util.nextLong();
+ String rs = Long.toHexString(r);
+ info.salt = rs.getBytes();
+ BigInteger g = SRPConf.getDefaultParams().g();
+ BigInteger N = SRPConf.getDefaultParams().N();
+
+ info.verifier = Util.calculateVerifier(username, password, info.salt, N, g);
+ info.g = g.toByteArray();
+ info.N = N.toByteArray();
+ log.info("Added user: "+username);
+ storeMap.put(username, info);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStoreMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStoreMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/service/PropertiesVerifierStoreMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,17 @@
+package org.jboss.book.security.ex3.service;
+
+import org.jboss.system.ServiceMBean;
+
+/** The JMX mbean interface for the SRP password verifier store.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision: 1.1 $
+*/
+public interface PropertiesVerifierStoreMBean extends ServiceMBean
+{ /** Get the jndi name for the SRPVerifierSource implementation binding.
+ */
+ public String getJndiName();
+ /** set the jndi name for the SRPVerifierSource implementation binding.
+ */
+ public void setJndiName(String jndiName);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/users.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/users.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3/users.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=theduke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.security.ex3a;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,64 @@
+package org.jboss.book.security.ex3a;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.debug("echo, arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex3a;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,56 @@
+package org.jboss.book.security.ex3a;
+
+import java.rmi.RemoteException;
+import javax.naming.InitialContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.login.LoginContext;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.PatternLayout;
+
+import org.jboss.logging.XLevel;
+import org.jboss.security.auth.callback.UsernamePasswordHandler;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ // Set up a simple configuration that logs on the console.
+ FileAppender fa = new FileAppender(new PatternLayout("%r[%c{1}], %m%n"), "ex3a-trace.log");
+ fa.setAppend(false);
+ Logger cat = Logger.getLogger("org.jboss.security");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ cat = Logger.getLogger("org.jboss.invocation");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ // Login using SRP
+ System.out.println("Logging in using the 'srpHA' configuration");
+ String username = args[0];
+ char[] password = args[1].toCharArray();
+ UsernamePasswordHandler handler = new UsernamePasswordHandler(username, password);
+ LoginContext lc = new LoginContext("srpHA", handler);
+ lc.login();
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean3a");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+ System.out.println("Created Echo");
+ // Make some calls across the cluster
+ for(int c = 1; c <= 4; c ++)
+ {
+ System.out.println("Echo.echo()#"+c+" = "+echo.echo("This is call "+c));
+ }
+ lc.logout();
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean3a</ejb-name>
+ <home>org.jboss.book.security.ex3a.EchoHome</home>
+ <remote>org.jboss.book.security.ex3a.Echo</remote>
+ <ejb-class>org.jboss.book.security.ex3a.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <security-role>
+ <role-name>Echo</role-name>
+ </security-role>
+
+ <method-permission>
+ <role-name>Echo</role-name>
+
+ <method>
+ <ejb-name>EchoBean3a</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The clustered version of the SRP services
+-->
+<server>
+ <!-- The custom JAAS login configuration that installs
+ a Configuration capable of dynamically updating the
+ config settings
+ -->
+ <mbean code="org.jboss.book.security.service.SecurityConfig"
+ name="jboss.docs.security:service=LoginConfig-EX3a">
+ <attribute name="AuthConfig">META-INF/login-config.xml</attribute>
+ <attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+
+ <!-- A service that establishes a distributed CachePolicy using the indicated
+ cluster partition state replication capabilities.
+ -->
+ <mbean code="org.jboss.book.security.ex3a.service.DistributedCacheService"
+ name="jboss.docs.security:service=SRPDistributedCache">
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ <attribute name="CacheJndiName">srp-test/SRPDistributedCache</attribute>
+ <attribute name="CacheTimeout">600</attribute>
+ <depends>jboss:service=DefaultPartition</depends>
+ </mbean>
+
+ <!-- The SRP service that provides the SRP RMI server and server side
+ authentication cache -->
+ <mbean code="org.jboss.security.srp.SRPService"
+ name="jboss.docs.security:service=SRPServiceHA">
+ <attribute name="VerifierSourceJndiName">srp-test/security-ex3</attribute>
+ <attribute name="JndiName">srp-test/SRPServerInterface</attribute>
+ <attribute name="AuthenticationCacheJndiName">srp-test/SRPDistributedCache</attribute>
+ <attribute name="ServerPort">0</attribute>
+ <depends>jboss.docs.security:service=PropertiesVerifierStore</depends>
+ <depends>jboss.docs.security:service=SRPDistributedCache</depends>
+ </mbean>
+
+ <!-- The SRP store handler service that provides the user password verifier
+ information -->
+ <mbean code="org.jboss.book.security.ex3.service.PropertiesVerifierStore"
+ name="jboss.docs.security:service=PropertiesVerifierStore">
+ <attribute name="JndiName">srp-test/security-ex3</attribute>
+ </mbean>
+
+ <!-- Expose the SRP service interface via clustered HTTP -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactoryHA"
+ name="jboss.docs.security:service=SRP/HA-HTTP">
+ <!-- The SRP service we are proxying -->
+ <attribute name="InvokerName">jboss.docs.security:service=SRPServiceHA</attribute>
+ <!-- Compose the invoker URL from the cluster node address -->
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/SRPInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ <attribute name="ExportedInterface">org.jboss.security.srp.SRPRemoteServerInterface</attribute>
+ <!-- The proxy will be available under this JNDI name -->
+ <attribute name="JndiName">srp-test/SRPServerInterfaceHA</attribute>
+ <!-- SRP is stateful and so the load balance policy must be sticky -->
+ <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.FirstAvailable</attribute>
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<jboss>
+ <security-domain>java:/jaas/security-ex3a</security-domain>
+
+ <container-configurations>
+ <!-- A custom container configuration for HA-RMI/HTTP -->
+ <container-configuration extends="Clustered Stateless SessionBean">
+ <container-name>HA HTTP Stateless SessionBean</container-name>
+ <home-invoker>jboss:service=invoker,type=httpHA</home-invoker>
+ <bean-invoker>jboss:service=invoker,type=httpHA</bean-invoker>
+ </container-configuration>
+ </container-configurations>
+
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean3a</ejb-name>
+ <configuration-name>HA HTTP Stateless SessionBean</configuration-name>
+ </session>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/roles.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/roles.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/roles.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=Echo,TheDuke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/users.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/users.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3a/users.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1 @@
+jduke=theduke
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,60 @@
+package org.jboss.book.security.ex3b;
+
+import java.rmi.RemoteException;
+import javax.naming.InitialContext;
+import javax.security.auth.login.LoginContext;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.PatternLayout;
+
+import org.jboss.logging.XLevel;
+import org.jboss.security.auth.callback.UsernamePasswordHandler;
+import org.jboss.book.security.ex3a.EchoHome;
+import org.jboss.book.security.ex3a.Echo;
+
+/** Test accessing EJBs that use clustered HTTP as the transport with SRP
+ * as the authentication mechanism. SRP also uses clustered HTTP as does
+ * JNDI. JNDI is also secured with a single read-only context that may be
+ * accessed by
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ // Set up a simple configuration that logs on the console.
+ FileAppender fa = new FileAppender(new PatternLayout("%r[%c{1}], %m%n"), "ex3b-trace.log");
+ fa.setAppend(false);
+ Logger cat = Logger.getLogger("org.jboss.security");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ cat = Logger.getLogger("org.jboss.invocation");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ // Login using SRP
+ System.out.println("Logging in using the 'srpHAReadOnlyJNDI' configuration");
+ String username = args[0];
+ char[] password = args[1].toCharArray();
+ UsernamePasswordHandler handler = new UsernamePasswordHandler(username, password);
+ LoginContext lc = new LoginContext("srpHAReadOnlyJNDI", handler);
+ lc.login();
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean3a");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+ System.out.println("Created Echo");
+ // Make some calls across the cluster
+ for(int c = 1; c <= 4; c ++)
+ {
+ System.out.println("Echo.echo()#"+c+" = "+echo.echo("This is call "+c));
+ }
+ lc.logout();
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/TstReadOnly.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/TstReadOnly.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/TstReadOnly.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,55 @@
+package org.jboss.book.security.ex3b;
+
+import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.PatternLayout;
+
+import org.jboss.logging.XLevel;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class TstReadOnly
+{
+ public static void main(String args[]) throws Exception
+ {
+ // Set up a simple configuration that logs on the console.
+ FileAppender fa = new FileAppender(new PatternLayout("%r[%c{1}], %m%n"), "ex3bro-trace.log");
+ fa.setAppend(false);
+ Logger cat = Logger.getLogger("org.jboss.security");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ cat = Logger.getLogger("org.jboss.invocation");
+ cat.setLevel(XLevel.TRACE);
+ cat.setAdditivity(false);
+ cat.addAppender(fa);
+
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
+ env.setProperty(Context.PROVIDER_URL, "http://localhost:8080/invoker/ReadOnlyJNDIFactoryHA");
+ System.out.println("JNDI env: "+env);
+ InitialContext iniCtx = new InitialContext(env);
+ // Do a lookup on the srp-readonly context
+ Object ref = iniCtx.lookup("srp-readonly/SRPServerInterfaceHA");
+ cat.info("srp-readonly/SRPServerInterfaceHA: "+ref);
+ // Do a lookup on another context that should fail
+ try
+ {
+ ref = iniCtx.lookup("jmx");
+ throw new IllegalStateException("Was able to lookup jmx: "+ref);
+ }
+ catch(NamingException e)
+ {
+ cat.info("lookup of jmx failed as expected", e);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/http-invoker-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/http-invoker-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/http-invoker-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE server>
+<!-- $Id: http-invoker-service.xml,v 1.1 2006/11/01 18:14:21 nrichards Exp $ -->
+
+<server>
+
+ <!-- The HTTP invoker service configration
+ -->
+ <mbean code="org.jboss.invocation.http.server.HttpInvoker"
+ name="jboss:service=invoker,type=http">
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/restricted/JMXInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.invocation.http.server.HttpInvokerHA"
+ name="jboss:service=invoker,type=httpHA">
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/EJBInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ </mbean>
+
+ <!-- Expose the HAJNDI service interface via clustered HTTP. This maps
+ to the ReadOnlyJNDIFactoryHA servlet URL
+ -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactoryHA"
+ name="jboss:service=invoker,type=httpHA,target=HAJNDI,readonly=true">
+ <depends>jboss:service=HAJNDI</depends>
+ <attribute name="InvokerName">jboss:service=HAJNDI</attribute>
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.FirstAvailable</attribute>
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ </mbean>
+ <!-- Expose the HAJNDI service interface via clustered HTTP. This maps
+ to the secured HAJNDIFactory servlet URL
+ -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactoryHA"
+ name="jboss:service=invoker,type=httpHA,target=HAJNDI,restricted=true">
+ <depends>jboss:service=HAJNDI</depends>
+ <attribute name="InvokerName">jboss:service=HAJNDI</attribute>
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/restricted/JMXInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.FirstAvailable</attribute>
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The clustered version of the SRP services
+-->
+<server>
+ <!-- The custom JAAS login configuration that installs
+ a Configuration capable of dynamically updating the
+ config settings
+ -->
+ <mbean code="org.jboss.book.security.service.SecurityConfig"
+ name="jboss.docs.security:service=LoginConfig-EX3b">
+ <attribute name="AuthConfig">META-INF/login-config.xml</attribute>
+ <attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+
+ <!-- A service that establishes a distributed CachePolicy using the indicated
+ cluster partition state replication capabilities.
+ -->
+ <mbean code="org.jboss.book.security.ex3a.service.DistributedCacheService"
+ name="jboss.docs.security:service=SRPDistributedCache">
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ <attribute name="CacheJndiName">srp-test/SRPDistributedCache</attribute>
+ <attribute name="CacheTimeout">600</attribute>
+ <depends>jboss:service=DefaultPartition</depends>
+ </mbean>
+
+ <!-- The SRP service that provides the SRP RMI server and server side
+ authentication cache -->
+ <mbean code="org.jboss.security.srp.SRPService"
+ name="jboss.docs.security:service=SRPServiceHA">
+ <attribute name="VerifierSourceJndiName">srp-test/security-ex3</attribute>
+ <attribute name="JndiName">srp-test/SRPServerInterface</attribute>
+ <attribute name="AuthenticationCacheJndiName">srp-test/SRPDistributedCache</attribute>
+ <attribute name="ServerPort">0</attribute>
+ <depends>jboss.docs.security:service=PropertiesVerifierStore</depends>
+ <depends>jboss.docs.security:service=SRPDistributedCache</depends>
+ </mbean>
+
+ <!-- The SRP store handler service that provides the user password verifier
+ information -->
+ <mbean code="org.jboss.book.security.ex3.service.PropertiesVerifierStore"
+ name="jboss.docs.security:service=PropertiesVerifierStore">
+ <attribute name="JndiName">srp-test/security-ex3</attribute>
+ </mbean>
+
+ <!-- Expose the SRP service interface via clustered HTTP -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactoryHA"
+ name="jboss.docs.security:service=SRPProxyFactory">
+ <!-- The SRP service we are proxying -->
+ <attribute name="InvokerName">jboss.docs.security:service=SRPServiceHA</attribute>
+ <!-- Compose the invoker URL from the cluster node address -->
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/SRPInvokerHAServlet</attribute>
+ <attribute name="UseHostName">false</attribute>
+ <attribute name="ExportedInterface">org.jboss.security.srp.SRPRemoteServerInterface</attribute>
+ <!-- The proxy will be available under this JNDI name. Note that this is
+ under the read-only JNDI context defined in the http-invoker web.xml
+ -->
+ <attribute name="JndiName">srp-readonly/SRPServerInterfaceHA</attribute>
+ <!-- SRP is stateful and so the load balance policy must be sticky -->
+ <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.FirstAvailable</attribute>
+ <attribute name="PartitionName">DefaultPartition</attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/web.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/web.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex3b/web.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+ <description>A Customized version of the http-invoker.sar/invoker.war
+ descriptor that sets up a read-only context
+ </description>
+ <filter>
+ <filter-name>ReadOnlyAccessFilterHA</filter-name>
+ <filter-class>org.jboss.invocation.http.servlet.ReadOnlyAccessFilter</filter-class>
+ <init-param>
+ <param-name>readOnlyContext</param-name>
+ <param-value>srp-readonly</param-value>
+ <description>The top level JNDI context the filter will enforce
+ read-only access on. If specified only Context.lookup operations
+ will be allowed on this context. Another other operations or lookups
+ on any other context will fail. Do not associate this filter with the
+ JMXInvokerServlets if you want unrestricted access.
+ </description>
+ </init-param>
+ <init-param>
+ <param-name>invokerName</param-name>
+ <param-value>jboss:service=HAJNDI</param-value>
+ <description>The JMX ObjectName of the HA-JNDI naming service mbean
+ </description>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>ReadOnlyAccessFilterHA</filter-name>
+ <url-pattern>/readonly/*</url-pattern>
+ </filter-mapping>
+
+<!-- ### Servlets -->
+ <servlet>
+ <servlet-name>EJBInvokerHAServlet</servlet-name>
+ <description>The EJBInvokerHAServlet handles requests to EJBs that
+ use the "jboss:service=invoker,type=httpHA" service as their invoker.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.InvokerServlet</servlet-class>
+ <init-param>
+ <param-name>invokerName</param-name>
+ <param-value>jboss:service=invoker,type=httpHA</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>JMXInvokerHAServlet</servlet-name>
+ <description>The JMXInvokerHAServlet receives posts containing serlized
+ MarshalledInvocation objects that are routed to the invoker given by
+ the invokerName init-param. The return content is a serialized
+ MarshalledValue containg the return value of the inovocation, or any
+ exception that may have been thrown.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.InvokerServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ReadOnlyJNDIFactoryHA</servlet-name>
+ <description>A servlet that exposes the JBoss JNDI Naming service stub
+ through http, but only for a single read-only context. The return content
+ is a serialized MarshalledValue containg the org.jnp.interfaces.Naming
+ stub.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
+ <init-param>
+ <param-name>namingProxyMBean</param-name>
+ <param-value>jboss:service=invoker,type=httpHA,target=HAJNDI,readonly=true</param-value>
+ <description>The HA capable invoker name.
+ </description>
+ </init-param>
+ <init-param>
+ <param-name>proxyAttribute</param-name>
+ <param-value>Proxy</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>HAJNDIFactory</servlet-name>
+ <description>A servlet that exposes the JBoss JNDI Naming service stub
+ through http. The return content is a serialized
+ MarshalledValue containg the org.jnp.interfaces.Naming stub. This
+ configuration handles requests for the HA JNDI naming service.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
+ <init-param>
+ <param-name>namingProxyMBean</param-name>
+ <param-value>jboss:service=invoker,type=httpHA,target=HAJNDI,restricted=true</param-value>
+ <description>The HA capable invoker name.
+ </description>
+ </init-param>
+ <init-param>
+ <param-name>proxyAttribute</param-name>
+ <param-value>Proxy</param-value>
+ </init-param>
+ <load-on-startup>3</load-on-startup>
+ </servlet>
+
+<!-- ### Servlet Mappings -->
+
+ <servlet-mapping>
+ <servlet-name>ReadOnlyJNDIFactoryHA</servlet-name>
+ <url-pattern>/ReadOnlyJNDIFactoryHA/*</url-pattern>
+ </servlet-mapping>
+ <!-- Alternate mappings that place the servlets under the restricted
+ path to required authentication for access. Remove the unsecure mappings
+ if only authenticated users should be allowed.
+ -->
+ <servlet-mapping>
+ <servlet-name>HAJNDIFactory</servlet-name>
+ <url-pattern>/restricted/HAJNDIFactory/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>EJBInvokerHAServlet</servlet-name>
+ <url-pattern>/EJBInvokerHAServlet/*</url-pattern>
+ </servlet-mapping>
+ <!-- An unsecured mapping used by the SRP authentication service -->
+ <servlet-mapping>
+ <servlet-name>JMXInvokerHAServlet</servlet-name>
+ <url-pattern>/SRPInvokerHAServlet/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JMXInvokerHAServlet</servlet-name>
+ <url-pattern>/restricted/JMXInvokerHAServlet/*</url-pattern>
+ </servlet-mapping>
+ <!-- A mapping for the JMXInvokerHAServlet that only allows invocations
+ of lookups under a read-only context. This is enforced by the
+ ReadOnlyAccessFilterHA.
+ -->
+ <servlet-mapping>
+ <servlet-name>JMXInvokerHAServlet</servlet-name>
+ <url-pattern>/readonly/JMXInvokerHAServlet/*</url-pattern>
+ </servlet-mapping>
+
+ <!-- An example security constraint that restricts access to the HTTP invoker
+ to users with the role HttpInvoker Edit the roles to what you want and
+ configure the WEB-INF/jboss-web.xml/security-domain element to reference
+ the security domain you want.
+ -->
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>HttpInvokers</web-resource-name>
+ <description>An example security config that only allows users with the
+ role HttpInvoker to access the HTTP invoker servlets
+ </description>
+ <url-pattern>/restricted/*</url-pattern>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>HttpInvoker</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>JBoss HTTP Invoker</realm-name>
+ </login-config>
+
+ <security-role>
+ <role-name>HttpInvoker</role-name>
+ </security-role>
+</web-app>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/Echo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/Echo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/Echo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.book.security.ex4;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface Echo extends EJBObject
+{
+ public String echo(String arg) throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,64 @@
+package org.jboss.book.security.ex4;
+
+import java.rmi.RemoteException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.log4j.Category;
+
+public class EchoBean implements SessionBean
+{
+ private static final Category log = Category.getInstance(EchoBean.class);
+ private SessionContext sessionCtx;
+
+ public void ejbCreate()
+ {
+ log.debug("ejbCreate: ");
+ }
+
+ public void ejbLoad()
+ {
+ log.debug("ejbLoad");
+ }
+
+ public void ejbRemove()
+ {
+ log.debug("ejbRemove");
+ }
+
+ public void ejbStore()
+ {
+ log.debug("ejbStore");
+ }
+
+ public void setSessionContext(SessionContext context)
+ {
+ sessionCtx = context;
+ log.debug("setSessionContext");
+ }
+
+ public void unsetSessionContext()
+ {
+ sessionCtx = null;
+ log.debug("unsetSessionContext");
+ }
+
+ public void ejbActivate()
+ {
+ log.debug("ejbActivate");
+ }
+ public void ejbPassivate()
+ {
+ log.debug("ejbPassivate");
+ }
+
+ public String echo(String arg)
+ {
+ log.debug("echo, arg="+arg);
+ return arg;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/EchoHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+package org.jboss.book.security.ex4;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EchoHome extends EJBHome
+{
+ public Echo create()
+ throws RemoteException, CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,35 @@
+package org.jboss.book.security.ex4;
+
+import java.rmi.RemoteException;
+import java.security.Security;
+import javax.naming.InitialContext;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+
+import org.jboss.logging.XLevel;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ // Install the Sun JSSE provider since we may not have JSSE installed
+ Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
+ // Configure log4j
+ BasicConfigurator.configure();
+ Category root = Category.getRoot();
+ root.setLevel(XLevel.TRACE);
+ InitialContext iniCtx = new InitialContext();
+ Object ref = iniCtx.lookup("EchoBean4");
+ EchoHome home = (EchoHome) ref;
+ Echo echo = home.create();
+ System.out.println("Created Echo");
+ System.out.println("Echo.echo()#1 = "+echo.echo("This is call 1"));
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/JSSE_install_check.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/JSSE_install_check.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/JSSE_install_check.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,24 @@
+package org.jboss.book.security.ex4;
+
+import java.net.*;
+import java.security.Security;
+import javax.net.ServerSocketFactory;
+import javax.net.ssl.*;
+
+public class JSSE_install_check
+{
+ public static void main(String[] args) throws Exception
+ {
+ Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
+
+ ServerSocketFactory factory = SSLServerSocketFactory.getDefault();
+ SSLServerSocket sslSocket = (SSLServerSocket) factory.createServerSocket(0);
+
+ String [] cipherSuites = sslSocket.getEnabledCipherSuites();
+ for(int i = 0; i < cipherSuites.length; i++)
+ {
+ System.out.println("Cipher Suite " + i +
+ " = " + cipherSuites[i]);
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/application.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/application.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/application.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+<!DOCTYPE application PUBLIC
+ "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+ "http://java.sun.com/dtd/application_1_3.dtd">
+
+<application>
+ <display-name>EJB/SSL ear</display-name>
+ <module>
+ <ejb>security-ex4.jar</ejb>
+ </module>
+</application>
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean4</ejb-name>
+ <home>org.jboss.book.security.ex4.EchoHome</home>
+ <remote>org.jboss.book.security.ex4.Echo</remote>
+ <ejb-class>org.jboss.book.security.ex4.EchoBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-app.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-app.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-app.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,5 @@
+<jboss-app>
+ <module>
+ <service>ex4/ssl-service.xml</service>
+ </module>
+</jboss-app>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
+ name="jboss.security:service=JaasSecurityDomain,domain=RMI+SSL">
+ <constructor>
+ <arg type="java.lang.String" value="RMI+SSL"/>
+ </constructor>
+ <attribute name="KeyStoreURL">example.keystore</attribute>
+ <attribute name="KeyStorePass">rmi+ssl</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"
+ name="jboss:service=invoker,type=jrmp,socketType=SSL">
+ <attribute name="RMIObjectPort">14445</attribute>
+ <attribute name="RMIClientSocketFactory">
+ org.jboss.security.ssl.RMISSLClientSocketFactory
+ </attribute>
+ <attribute name="RMIServerSocketFactory">
+ org.jboss.security.ssl.RMISSLServerSocketFactory
+ </attribute>
+ <attribute name="SecurityDomain">java:/jaas/RMI+SSL</attribute>
+ <depends>jboss.security:service=JaasSecurityDomain,domain=RMI+SSL</depends>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/ex4/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EchoBean4</ejb-name>
+ <configuration-name>Standard Stateless SessionBean</configuration-name>
+ <invoker-bindings>
+ <invoker>
+ <invoker-proxy-binding-name>stateless-ssl-invoker</invoker-proxy-binding-name>
+ </invoker>
+ </invoker-bindings>
+ </session>
+ </enterprise-beans>
+
+ <invoker-proxy-bindings>
+ <invoker-proxy-binding>
+ <name>stateless-ssl-invoker</name>
+ <invoker-mbean>jboss:service=invoker,type=jrmp,socketType=SSL</invoker-mbean>
+ <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
+ <proxy-factory-config>
+ <client-interceptors>
+ <home>
+ <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </home>
+ <bean>
+ <interceptor>org.jboss.proxy.ejb.StatelessSessionInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </bean>
+ </client-interceptors>
+ </proxy-factory-config>
+ </invoker-proxy-binding>
+ </invoker-proxy-bindings>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/example.keystore
===================================================================
(Binary files differ)
Property changes on: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/example.keystore
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/log4j.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/log4j.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/log4j.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+log4j.rootCategory=DEBUG, Default, Console
+
+### The console appender
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+log4j.appender.Console.Threshold=DEBUG
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.ConversionPattern=[%p,%c{1}] %m%n
+
+# Enable TRACE priority in org.jboss.security category
+#log4j.category.org.jboss.security=TRACE#org.jboss.logging.XPriority
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/login-config.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/login-config.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/login-config.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,54 @@
+<?xml version='1.0'?>
+<!DOCTYPE policy PUBLIC
+ "-//JBoss//DTD JBOSS Security Config 3.0//EN"
+ "http://www.jboss.org/j2ee/dtd/security_config.dtd">
+
+<!-- The JAAS login configuration file for the java:/jaas/security-ex1
+security domain used by the security-spec test case
+-->
+<policy>
+ <application-policy name="security-ex1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
+ flag="required">
+ <module-option name="unauthenticatedIdentity">anonymous</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <application-policy name="security-ex2">
+ <authentication>
+ <login-module code="org.jboss.book.security.ex2.JndiUserAndPass"
+ flag="required">
+ <module-option name="userPathPrefix">/security/store/password</module-option>
+ <module-option name="rolesPathPrefix">/security/store/roles</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <application-policy name="security-ex3">
+ <authentication>
+ <login-module code="org.jboss.security.srp.jaas.SRPCacheLoginModule"
+ flag="required">
+ <module-option name="cacheJndiName">srp-test/AuthenticationCache</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
+ flag="required">
+ <module-option name="password-stacking">useFirstPass</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <application-policy name="security-ex3a">
+ <authentication>
+ <login-module code="org.jboss.security.srp.jaas.SRPCacheLoginModule"
+ flag="required">
+ <module-option name="cacheJndiName">srp-test/SRPDistributedCache</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
+ flag="required">
+ <module-option name="password-stacking">useFirstPass</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+</policy>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheService.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheService.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheService.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,228 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.book.security.service;
+
+import java.lang.reflect.Method;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.util.Vector;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+
+import org.jboss.ha.framework.interfaces.DistributedState;
+import org.jboss.ha.framework.interfaces.DistributedState.DSListenerEx;
+import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.HAPartition.HAMembershipListener;
+import org.jboss.ha.framework.server.util.DistributedTimedCachePolicy;
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.system.ServiceMBeanSupport;
+
+/** The cluster parition membership monitor and distributed cache
+ test mbean implementation
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public class DistributedCacheService extends ServiceMBeanSupport
+ implements DistributedCacheServiceMBean, HAMembershipListener, DSListenerEx
+{
+ private String jndiName;
+ private String partitionName = "Default";
+ private HAPartition partition;
+ private DistributedState map;
+ private DistributedTimedCachePolicy cache;
+ private int cacheTimeout = 1800;
+
+// --- Begin ServiceMBeanSupport overriden methods
+ protected void startService() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ String partitionJndiName = "/HAPartition/" + partitionName;
+ partition = (HAPartition) ctx.lookup(partitionJndiName);
+ map = partition.getDistributedStateService();
+ cache = new DistributedTimedCachePolicy(jndiName, partitionName, cacheTimeout);
+ cache.create();
+ cache.start();
+ // Bind the cache into JNDI
+ Name name = ctx.getNameParser("").parse(jndiName);
+ NonSerializableFactory.rebind(name, cache, true);
+
+ // Register as a listener of cache changes
+ map.registerDSListenerEx(jndiName, this);
+ log.info("Registered as DMListener for category="+jndiName);
+ // Register as a listener of cluster membership changes
+ partition.registerMembershipListener(this);
+ log.info("Registered as MembershipListener");
+ }
+
+ protected void stopService() throws Exception
+ {
+ cache.stop();
+ map.unregisterDSListenerEx(jndiName, this);
+ partition.unregisterMembershipListener(this);
+ }
+// --- End ServiceMBeanSupport overriden methods
+
+// --- Begin DistributedCacheServiceMBean interface methods
+ public String getPartitionName()
+ {
+ return partitionName;
+ }
+ public void setPartitionName(String name)
+ {
+ this.partitionName = name;
+ }
+
+ public String getCacheJndiName()
+ {
+ return jndiName;
+ }
+ public void setCacheJndiName(String name)
+ {
+ this.jndiName = name;
+ }
+
+ public int getCacheTimeout()
+ {
+ return cacheTimeout;
+ }
+ public void setCacheTimeout(int timeoutSecs)
+ {
+ this.cacheTimeout = timeoutSecs;
+ }
+
+ public Vector getClusterNodes()
+ {
+ Vector view = null;
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ String jndiName = "/HAPartition/" + partitionName;
+ HAPartition partition = (HAPartition) ctx.lookup(jndiName);
+ view = partition.getCurrentView();
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to access HAPartition state", e);
+ }
+ return view;
+ }
+
+ public Object get(String key)
+ {
+ return cache.get(key);
+ }
+ public void set(String key, String value)
+ {
+ cache.insert(key, value);
+ }
+// --- End DistributedCacheServiceMBean interface methods
+
+// --- Begin HAMembershipListener interface methods
+ /** Called when a new partition topology occurs.
+ * @param deadMembers A list of nodes that have died since the previous view
+ * @param newMembers A list of nodes that have joined the partition since
+ * the previous view
+ * @param allMembers A list of nodes that built the current view
+ */
+ public void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers)
+ {
+ log.info("DeadMembers: size="+deadMembers.size());
+ for(int m = 0; m < deadMembers.size(); m ++)
+ {
+ AddressPort addrInfo = getMemberAddress(deadMembers.get(m));
+ log.info(addrInfo);
+ }
+ log.info("NewMembers: size="+newMembers.size());
+ for(int m = 0; m < newMembers.size(); m ++)
+ {
+ AddressPort addrInfo = getMemberAddress(newMembers.get(m));
+ log.info(addrInfo);
+ }
+ log.info("AllMembers: size="+allMembers.size());
+ for(int m = 0; m < allMembers.size(); m ++)
+ {
+ AddressPort addrInfo = getMemberAddress(allMembers.get(m));
+ log.info(addrInfo);
+ }
+ }
+// --- End HAMembershipListener interface methods
+
+// --- Begin DMListener interface methods
+ public void valueHasChanged(String category, Serializable key,
+ Serializable value, boolean locallyModified)
+ {
+ log.info("valueHasChanged, category="+category+", key="+key
+ +", value="+value+", locallyModified="+locallyModified);
+ }
+ public void keyHasBeenRemoved (String category, Serializable key,
+ Serializable value, boolean locallyModified)
+ {
+ log.info("keyHasBeenRemoved, category="+category+", key="+key
+ +", value="+value+", locallyModified="+locallyModified);
+ }
+// --- End DMListener interface methods
+
+ /** Use reflection to access the address InetAddress and port if they exist
+ * in the Address implementation
+ */
+ private AddressPort getMemberAddress(Object addr)
+ {
+ AddressPort info = null;
+ try
+ {
+ Class[] parameterTypes = {};
+ Object[] args = {};
+ Method getIpAddress = addr.getClass().getMethod("getIpAddress", parameterTypes);
+ InetAddress inetAddr = (InetAddress) getIpAddress.invoke(addr, args);
+ Method getPort = addr.getClass().getMethod("getPort", parameterTypes);
+ Integer port = (Integer) getPort.invoke(addr, args);
+ info = new AddressPort(inetAddr, port);
+ }
+ catch(Exception e)
+ {
+ // Try to access the address info from the getName -> addr:port string
+ try
+ {
+ Class[] parameterTypes = {};
+ Object[] args = {};
+ Method getName = addr.getClass().getMethod("getName", parameterTypes);
+ String id = (String) getName.invoke(addr, args);
+ String addrString = id;
+ Integer port = null;
+ int colon = id.indexOf(':');
+ if( colon > 0 )
+ {
+ addrString = id.substring(0, colon);
+ port = Integer.valueOf(id.substring(colon+1));
+ }
+ InetAddress inetAddr = InetAddress.getByName(addrString);
+ info = new AddressPort(inetAddr, port);
+ }
+ catch(Exception e2)
+ {
+ log.warn("Failed to obtain InetAddress/port from addr: "+addr, e);
+ }
+ }
+ return info;
+ }
+
+ static class AddressPort
+ {
+ InetAddress addr;
+ Integer port;
+ AddressPort(InetAddress addr, Integer port)
+ {
+ this.addr = addr;
+ this.port = port;
+ }
+ public String toString()
+ {
+ return "{host("+addr+"), port("+port+")}";
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheServiceMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheServiceMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/DistributedCacheServiceMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,52 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.book.security.service;
+
+import java.util.Vector;
+import org.jboss.system.Service;
+
+/** A utility mbean that monitors membership of a cluster parition and
+ * establishes a DistributedTimedCachePolicy
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface DistributedCacheServiceMBean extends Service
+{
+ /** Get the cluster parition name the mbean is monitoring
+ */
+ public String getPartitionName();
+ /** Set the cluster parition name the mbean is monitoring
+ */
+ public void setPartitionName(String name);
+
+ /** Get the JNDI name under which the CachePolicy is bound into JNDI
+ */
+ public String getCacheJndiName();
+ /** Set the JNDI name under which the CachePolicy is bound into JNDI
+ */
+ public void setCacheJndiName(String name);
+
+ /** Get the cache timeout (seconds)
+ */
+ public int getCacheTimeout();
+ /** Set the cache timeout (seconds)
+ */
+ public void setCacheTimeout(int timeoutSecs);
+
+ /** Get the current cluster parition membership info
+ *@return a Vector of org.javagroups.Address implementations, for example,
+ *org.javagroups.stack.IpAddress
+ */
+ public Vector getClusterNodes();
+
+ /** Get a value from the cache policy
+ */
+ public Object get(String key);
+ /** Set a value in the cache policy
+ */
+ public void set(String key, String value);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfig.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfig.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfig.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.book.security.service;
+
+import java.net.URL;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.security.auth.login.XMLLoginConfigMBean;
+import org.jboss.system.ServiceMBeanSupport;
+
+/** A security config mbean that loads an xml login configuration and
+ pushes a XMLLoginConfig instance onto the the config stack managed by
+ the SecurityConfigName mbean(default=jboss.security:service=XMLLoginConfig).
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public class SecurityConfig extends ServiceMBeanSupport
+ implements SecurityConfigMBean
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ private String authConf = "login-config.xml";
+ private String[] loadedDomains;
+ private ObjectName mainSecurityConfig;
+ private XMLLoginConfigMBean config;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public SecurityConfig()
+ {
+ setSecurityConfigName("jboss.security:service=XMLLoginConfig");
+ }
+
+ public String getName()
+ {
+ return "JAAS Login Config";
+ }
+ public String getSecurityConfigName()
+ {
+ return mainSecurityConfig.toString();
+ }
+ public void setSecurityConfigName(String objectName)
+ {
+ try
+ {
+ mainSecurityConfig = new ObjectName(objectName);
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to create ObjectName", e);
+ }
+ }
+
+ /** Get the resource path to the JAAS login configuration file to use.
+ */
+ public String getAuthConfig()
+ {
+ return authConf;
+ }
+
+ /** Set the resource path to the JAAS login configuration file to use.
+ The default is "login-config.xml".
+ */
+ public void setAuthConfig(String authConf)
+ {
+ this.authConf = authConf;
+ }
+
+ /** Start the service. This entails locating the AuthConfig resource and
+ * then loading this into the XMLLoginConfigMBean given by the
+ * SecurityConfigName mbean.
+ */
+ protected void startService() throws Exception
+ {
+ // Look for the authConf as resource
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ URL loginConfig = loader.getResource(authConf);
+ if( loginConfig != null )
+ {
+ log.info("Using JAAS AuthConfig: "+loginConfig.toExternalForm());
+ config = (XMLLoginConfigMBean) MBeanProxy.get(XMLLoginConfigMBean.class,
+ mainSecurityConfig, server);
+ loadedDomains = config.loadConfig(loginConfig);
+ }
+ else
+ {
+ log.warn("No AuthConfig resource found");
+ }
+ }
+
+ protected void stopService() throws Exception
+ {
+ if( loadedDomains != null )
+ config.removeConfigs(loadedDomains);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfigMBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfigMBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/book/security/service/SecurityConfigMBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.book.security.service;
+
+import org.jboss.system.ServiceMBean;
+
+/** An mbean interface for a config service that pushes an xml based
+ javax.security.auth.login.Configuration onto the config stack managed by
+ the mbean whose name is given by the SecurityConfigName attribute.
+
+ @see org.jboss.security.plugins.SecurityConfigMBean
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 1.1 $
+ */
+public interface SecurityConfigMBean extends ServiceMBean
+{
+ /** Get the classpath resource name of the security configuration file */
+ public String getAuthConfig();
+ /** Set the classpath resource name of the security configuration file */
+ public void setAuthConfig(String configURL);
+ /** Get the name of the SecurityConfig mbean whose pushLoginConfig and
+ popLoginConfig ops will be used to install and remove the xml login config*/
+ public String getSecurityConfigName();
+ /** Set the name of the SecurityConfig mbean whose pushLoginConfig and
+ popLoginConfig ops will be used to install and remove the xml login config*/
+ public void setSecurityConfigName(String objectName);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ContactInfo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ContactInfo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ContactInfo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,124 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.io.Serializable;
+
+/**
+ * ContactInfo contains a cell number, a pager number, and email
+ * address.
+ */
+public class ContactInfo
+ implements Serializable
+{
+ /** The cell phone number. */
+ private PhoneNumber cell;
+
+ /** The pager number. */
+ private PhoneNumber pager;
+
+ /** The email address */
+ private String email;
+
+ /**
+ * Creates empty contact info.
+ */
+ public ContactInfo() {
+ }
+
+ /**
+ * Gets the cell phone number.
+ * @return the cell phone number
+ */
+ public PhoneNumber getCell() {
+ return cell;
+ }
+
+ /**
+ * Sets the cell phone number.
+ * @param cell the new cell phone number.
+ */
+ public void setCell(PhoneNumber cell) {
+ this.cell = cell;
+ }
+
+ /**
+ * Gets the pager number.
+ * @return the pager number
+ */
+ public PhoneNumber getPager() {
+ return pager;
+ }
+
+ /**
+ * Sets the pager number.
+ * @param pager the new pager number.
+ */
+ public void setPager(PhoneNumber pager) {
+ this.pager = pager;
+ }
+
+ /**
+ * Gets the email address.
+ * @return the email address
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Sets the email address.
+ * @param email the new email address
+ */
+ public void setEmail(String email) {
+ this.email = email.toLowerCase();
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof ContactInfo)) {
+ return false;
+ }
+ ContactInfo contactInfo = (ContactInfo)o;
+ return isEqual(contactInfo.cell, cell) &&
+ isEqual(contactInfo.pager, pager) &&
+ isEqual(contactInfo.email, email);
+ }
+
+ /**
+ * Equals helper method that handles null values.
+ * @param o1 first object to compare
+ * @param o2 second object to compare
+ * @return true if both objects are null or they are equivalent; false
+ * otherwise
+ */
+ private static boolean isEqual(Object o1, Object o2) {
+ if (o1 == null) {
+ return o2 == null;
+ }
+ return o1 == o2 || o1.equals(o2);
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + (cell==null ? 0 : cell.hashCode());
+ result = 37 * result + (pager==null ? 0: pager.hashCode());
+ result = 37 * result + (email==null ? 0 : email.hashCode());
+ return result;
+ }
+
+ /**
+ * Returns the string representation of this contact info.
+ * The exact details of the representation are unspecified and subject to
+ * change, but the following may be regarded as typical:
+ *
+ * "[ContactInfo: cell=(123) 456-7890, pager=(123) 456-7890,
+ * email=someone at somewhere.com]"
+ */
+ public String toString() {
+ return "[ContactInfo: " +
+ "cell=" + cell + ", " +
+ "pager=" + pager + ", " +
+ "email=" + email + "]";
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalSetUp.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalSetUp.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalSetUp.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,122 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.test.util.ejb.EJBTestCase;
+
+public class CrimePortalSetUp extends EJBTestCase
+ implements CrimePortalTestConstants
+{
+
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite("CrimePortalSetUp");
+ testSuite.addTestSuite(CrimePortalSetUp.class);
+ return testSuite;
+ }
+
+ public CrimePortalSetUp(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Looks up all of the home interfaces and creates the initial data.
+ * @throws Exception if a problem occures while finding the home interfaces,
+ * or if an problem occures while createing the initial data
+ */
+ public void testSetUp() throws Exception
+ {
+ InitialContext jndi = new InitialContext();
+
+ OrganizationHome organizationHome =
+ (OrganizationHome) jndi.lookup("crimeportal/Organization");
+
+ GangsterHome gangsterHome =
+ (GangsterHome) jndi.lookup("crimeportal/Gangster");
+
+ JobHome jobHome = (JobHome) jndi.lookup("crimeportal/Job");
+
+ LocationHome locationHome =
+ (LocationHome) jndi.lookup("crimeportal/Location");
+
+ // Create some organizations
+ Organization yakuza =
+ organizationHome.create("Yakuza", "Japanese Gangsters");
+ Organization mafia =
+ organizationHome.create("Mafia", "Italian Bad Guys");
+ Organization triads =
+ organizationHome.create("Triads", "Kung Fu Movie Extras");
+
+ // Create some gangsters
+ Gangster yojimbo =
+ gangsterHome.create(YOJIMBO, "Yojimbo", "Bodyguard", 7, yakuza);
+ ContactInfo contactInfo = new ContactInfo();
+ contactInfo.setEmail("yojimbo439 at yakuza.jp");
+ contactInfo.setCell(new PhoneNumber(123, 456, 7890));
+ contactInfo.setPager(new PhoneNumber(111, 222, 3333));
+ yojimbo.setContactInfo(contactInfo);
+ yojimbo.setHangout(locationHome.create("Red Dragon Basement",
+ "1452 Stockton Street", "San Fran", "CA", 94108));
+
+ Gangster takeshi =
+ gangsterHome.create(TAKESHI, "Takeshi", "Master", 10, yakuza);
+ takeshi.setHangout(locationHome.create("Flaming Fist Dojo",
+ "598 Jackson Street", "San Fran", "CA", 94133));
+ Gangster yuriko =
+ gangsterHome.create(YURIKO, "Yuriko", "Four finger", 4, yakuza);
+ yuriko.setHangout(locationHome.create("Sister's House",
+ "1411 Powell Street", "San Fran", "CA", 94133));
+
+ Gangster chow =
+ gangsterHome.create(CHOW, "Chow", "Killer", 9, triads);
+ chow.setHangout(locationHome.create("Golden Gate Fortune Cookie Factory",
+ "56 Ross Alley", "San Fran", "CA", 94133));
+ Gangster shogi =
+ gangsterHome.create(SHOGI, "Shogi", "Lightning", 8, triads);
+ shogi.setHangout(locationHome.create("The Wok Shop",
+ "718 Grant Avenue", "San Fran", "CA", 94133));
+
+ Gangster valentino =
+ gangsterHome.create(VALENTINO, "Valentino", "Pizza-Face", 4, mafia);
+ valentino.setHangout(locationHome.create("Luca's",
+ "299 Madison Avenue", "New York", "NY", 10017));
+ Gangster toni =
+ gangsterHome.create(TONI, "Toni", "Toohless", 2, mafia);
+ toni.setHangout(locationHome.create("Hotel Workers Union Shop",
+ "225 S. Canal Street", "Chicago", "IL", 60661));
+ Gangster corleone =
+ gangsterHome.create(CORLEONE, "Corleone", "Godfather", 6, mafia);
+ corleone.setHangout(locationHome.create("Black Diamond Casino",
+ "9555 Las Vegas Blvd South", "Las Vegas", "NV", 89109));
+
+ // Assign the bosses
+ yakuza.setTheBoss(takeshi);
+ triads.setTheBoss(chow);
+ mafia.setTheBoss(corleone);
+
+ // Create some jobs
+ Job jewler = jobHome.create("10th Street Jeweler Heist");
+ jewler.setScore(5000);
+ jewler.setSetupCost(50);
+
+ Job train = jobHome.create("The Greate Train Robbery");
+ train.setScore(2000000);
+ train.setSetupCost(500000);
+
+ Job liquorStore = jobHome.create("Cheap Liquor Snatch and Grab");
+ liquorStore.setScore(50);
+ liquorStore.setSetupCost(0);
+
+ // assign some gangsters to the jobs
+ jewler.getGangsters().add(valentino);
+ jewler.getGangsters().add(corleone);
+
+ train.getGangsters().add(yojimbo);
+ train.getGangsters().add(chow);
+
+ liquorStore.getGangsters().add(chow);
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTearDown.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTearDown.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTearDown.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,68 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Iterator;
+import javax.naming.InitialContext;
+import javax.ejb.EJBLocalObject;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.test.util.ejb.EJBTestCase;
+
+public class CrimePortalTearDown extends EJBTestCase
+{
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite("CrimePortalTearDown");
+ testSuite.addTestSuite(CrimePortalTearDown.class);
+ return testSuite;
+ }
+
+ public CrimePortalTearDown(String name)
+ {
+ super(name);
+ }
+
+ public void testTearDown() throws Exception
+ {
+ InitialContext jndi = new InitialContext();
+
+ // delete all organizations
+ OrganizationHome organizationHome =
+ (OrganizationHome) jndi.lookup("crimeportal/Organization");
+ Iterator organizations = organizationHome.findAll().iterator();
+ while (organizations.hasNext())
+ {
+ EJBLocalObject ejb = (EJBLocalObject) organizations.next();
+ ejb.remove();
+ }
+
+ // delete all gangsters (should be cascade-deleted, but be safe)
+ GangsterHome gangsterHome =
+ (GangsterHome) jndi.lookup("crimeportal/Gangster");
+ Iterator gangsters = gangsterHome.findAll().iterator();
+ while (gangsters.hasNext())
+ {
+ EJBLocalObject ejb = (EJBLocalObject) gangsters.next();
+ ejb.remove();
+ }
+
+ // delete all jobs
+ JobHome jobHome = (JobHome) jndi.lookup("crimeportal/Job");
+ Iterator jobs = jobHome.findAll().iterator();
+ while (jobs.hasNext())
+ {
+ EJBLocalObject ejb = (EJBLocalObject) jobs.next();
+ ejb.remove();
+ }
+
+ // delete all locations (should be cascade-deleted, but be safe)
+ LocationHome locationHome =
+ (LocationHome) jndi.lookup("crimeportal/Location");
+ Iterator locations = locationHome.findAll().iterator();
+ while (locations.hasNext())
+ {
+ EJBLocalObject ejb = (EJBLocalObject) locations.next();
+ ejb.remove();
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTest.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTest.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTest.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,200 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Iterator;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.test.util.ejb.EJBTestCase;
+
+public class CrimePortalTest extends EJBTestCase
+ implements CrimePortalTestConstants
+{
+
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite("CrimePortalTest");
+ testSuite.addTestSuite(CrimePortalTest.class);
+ return testSuite;
+ }
+
+ public CrimePortalTest(String name)
+ {
+ super(name);
+ }
+
+ private OrganizationHome organizationHome;
+ private GangsterHome gangsterHome;
+ private JobHome jobHome;
+ private LocationHome locationHome;
+
+ /**
+ * Looks up all of the home interfaces and creates the initial data.
+ * Looking up objects in JNDI is expensive, so it should be done once
+ * and cached.
+ * @throws Exception if a problem occures while finding the home interfaces,
+ * or if an problem occures while createing the initial data
+ */
+ public void setUp() throws Exception
+ {
+ InitialContext jndi = new InitialContext();
+
+ organizationHome =
+ (OrganizationHome) jndi.lookup("crimeportal/Organization");
+
+ gangsterHome = (GangsterHome) jndi.lookup("crimeportal/Gangster");
+
+ jobHome = (JobHome) jndi.lookup("crimeportal/Job");
+
+ locationHome = (LocationHome) jndi.lookup("crimeportal/Location");
+ }
+
+ /** Test Organization-Gangster relationship */
+ public void testOrganization() throws Exception
+ {
+ Organization yakuza = organizationHome.findByPrimaryKey("Yakuza");
+ Collection gangsters = yakuza.getMemberGangsters();
+ assertEquals(3, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(YOJIMBO)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(YURIKO)));
+ }
+
+ /** Test find bad dudes query */
+ public void testFindBadDudes_ejbql() throws Exception
+ {
+ Collection gangsters = gangsterHome.findBadDudes_ejbql(5);
+ assertEquals(5, gangsters.size());
+
+ assertTrue(gangsters.contains(
+ gangsterHome.findByPrimaryKey(TAKESHI)));
+ assertTrue(gangsters.contains(
+ gangsterHome.findByPrimaryKey(CHOW)));
+ assertTrue(gangsters.contains(
+ gangsterHome.findByPrimaryKey(SHOGI)));
+ assertTrue(gangsters.contains(
+ gangsterHome.findByPrimaryKey(YOJIMBO)));
+ assertTrue(gangsters.contains(
+ gangsterHome.findByPrimaryKey(CORLEONE)));
+ }
+
+ /** Test find bad dudes query */
+ public void testFindBadDudes_jbossql() throws Exception
+ {
+ Collection gangsters = gangsterHome.findBadDudes_jbossql(5);
+ assertEquals(5, gangsters.size());
+
+ // gangsters should be in the following order
+ Iterator iter = gangsters.iterator();
+ assertEquals(gangsterHome.findByPrimaryKey(TAKESHI), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(CHOW), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(SHOGI), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(YOJIMBO), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(CORLEONE), iter.next());
+ }
+
+ /** Test find bad dudes query */
+ public void testFindBadDudes_declaredsql() throws Exception
+ {
+ Collection gangsters = gangsterHome.findBadDudes_declaredsql(5);
+ assertEquals(5, gangsters.size());
+
+ // gangsters should be in the following order
+ Iterator iter = gangsters.iterator();
+ assertEquals(gangsterHome.findByPrimaryKey(TAKESHI), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(CHOW), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(SHOGI), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(YOJIMBO), iter.next());
+ assertEquals(gangsterHome.findByPrimaryKey(CORLEONE), iter.next());
+ }
+
+ /** Test select boss query */
+ public void testSelectBoss_ejbql() throws Exception
+ {
+ Set gangsters = gangsterHome.selectBoss_ejbql(" Yojimbo ");
+ assertEquals(1, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+
+ gangsters = gangsterHome.selectBoss_ejbql(" Takeshi ");
+ assertEquals(1, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+
+ gangsters = gangsterHome.selectBoss_ejbql("non-existant");
+ assertEquals(0, gangsters.size());
+ }
+
+ /** Test select boss query */
+ public void testSelectBoss_declaredsql() throws Exception
+ {
+ Set gangsters = gangsterHome.selectBoss_declaredsql(" YoJIMbO ");
+ assertEquals(1, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+
+ gangsters = gangsterHome.selectBoss_declaredsql(" TaKeShI ");
+ assertEquals(1, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+
+ gangsters = gangsterHome.selectBoss_declaredsql("non-existant");
+ assertEquals(0, gangsters.size());
+ }
+
+ /** Test select gangsters in states query */
+ public void testSelectInStates() throws Exception
+ {
+ Set states = new HashSet();
+ states.add("CA");
+ states.add("NV");
+ states.add("OR");
+ states.add("WA");
+
+ Collection gangsters = gangsterHome.selectInStates(states);
+ assertEquals(6, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(TAKESHI)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(YURIKO)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(CHOW)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(SHOGI)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(YOJIMBO)));
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(CORLEONE)));
+ }
+
+ /** Test select operating zip codes query */
+ public void testSelectOperatingZipCodes_declaredsql() throws Exception
+ {
+ Collection zipCodes =
+ organizationHome.selectOperatingZipCodes_declaredsql(" YaKuZa");
+ assertEquals(2, zipCodes.size());
+
+ // zip codes should be in the following order
+ Iterator iter = zipCodes.iterator();
+ assertEquals(new Integer(94108), iter.next());
+ assertEquals(new Integer(94133), iter.next());
+ }
+
+ /** Test select gangsters in states query */
+ public void testFindByPrimaryKeys() throws Exception
+ {
+ Set states = new HashSet();
+ states.add("CA");
+ states.add("NV");
+ states.add("OR");
+ states.add("WA");
+
+ Set gangsters = gangsterHome.selectInStates(states);
+ assertEquals(6, gangsters.size());
+ assertTrue(gangsters.contains(gangsterHome.findByPrimaryKey(CORLEONE)));
+ }
+
+ /** Test loading of contact info */
+ public void testContactInfo() throws Exception
+ {
+ Gangster yojimbo = gangsterHome.findByPrimaryKey(YOJIMBO);
+ ContactInfo contactInfo = yojimbo.getContactInfo();
+ assertNotNull(contactInfo);
+ assertEquals("yojimbo439 at yakuza.jp", contactInfo.getEmail());
+ assertEquals(new PhoneNumber(123, 456, 7890), contactInfo.getCell());
+ assertEquals(new PhoneNumber(111, 222, 3333), contactInfo.getPager());
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTestConstants.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTestConstants.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/CrimePortalTestConstants.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+package org.jboss.cmp2.crimeportal;
+
+public interface CrimePortalTestConstants {
+ public final Integer YOJIMBO = new Integer(0);
+ public final Integer TAKESHI = new Integer(1);
+ public final Integer YURIKO = new Integer(2);
+ public final Integer CHOW = new Integer(3);
+ public final Integer SHOGI = new Integer(4);
+ public final Integer VALENTINO = new Integer(5);
+ public final Integer TONI = new Integer(6);
+ public final Integer CORLEONE = new Integer(7);
+}
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Gangster.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Gangster.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Gangster.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,30 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Set;
+import javax.ejb.EJBLocalObject;
+
+public interface Gangster
+ extends EJBLocalObject
+{
+ Integer getGangsterId();
+
+ String getName();
+
+ String getNickName();
+ void setNickName(String nickName);
+
+ int getBadness();
+ void setBadness(int badness);
+
+ ContactInfo getContactInfo();
+ void setContactInfo(ContactInfo contactInfo);
+
+ Organization getOrganization();
+
+ Set getJobs();
+
+ Set getEnemies();
+
+ Location getHangout();
+ void setHangout(Location hangout);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,156 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+import javax.ejb.CreateException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.FinderException;
+import org.apache.log4j.Category;
+
+public abstract class GangsterBean
+ implements EntityBean
+{
+ private EntityContext ctx;
+ private Category log = Category.getInstance(getClass());
+
+ public Integer ejbCreate(Integer id, String name, String nickName)
+ throws CreateException
+ {
+ log.info("Creating Gangster " + id + " '" + nickName + "' "+ name);
+ setGangsterId(id);
+ setName(name);
+ setNickName(nickName);
+ return null;
+ }
+
+ public void ejbPostCreate(Integer id, String name, String nickName) { }
+
+ public Integer ejbCreate(
+ Integer id,
+ String name,
+ String nickName,
+ int badness,
+ Organization organization) throws CreateException
+ {
+ log.info("Creating Gangster " + id + " '" + nickName + "' "+ name);
+ setGangsterId(id);
+ setName(name);
+ setNickName(nickName);
+ setBadness(badness);
+ return null;
+ }
+
+ public void ejbPostCreate(Integer id,
+ String name,
+ String nickName,
+ int badness,
+ Organization organization)
+ {
+ setOrganization(organization);
+ }
+
+ // CMP field accessors ----------------------------------------------
+ public abstract Integer getGangsterId();
+ public abstract void setGangsterId(Integer gangsterId);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract String getNickName();
+ public abstract void setNickName(String nickName);
+
+ public abstract int getBadness();
+ public abstract void setBadness(int badness);
+
+ public abstract ContactInfo getContactInfo();
+ public abstract void setContactInfo(ContactInfo contactInfo);
+
+ // CMR field accessors --------------------------------------------
+ public abstract Organization getOrganization();
+ public abstract void setOrganization(Organization org);
+
+ public abstract Set getJobs();
+ public abstract void setJobs(Set jobs);
+
+ public abstract Set getEnemies();
+ public abstract void setEnemies(Set enemies);
+
+ public abstract Location getHangout();
+ public abstract void setHangout(Location hangout);
+
+ // ejbSelect methods -------------------------------------------------------
+ public abstract Set ejbSelectBoss_ejbql(String name) throws FinderException;
+ public abstract Set ejbSelectBoss_declaredsql(String name)
+ throws FinderException;
+
+ public abstract Set ejbSelectAccomplices(Gangster g) throws FinderException;
+
+ public abstract Set ejbSelectGeneric(String jbossQl, Object[] arguments)
+ throws FinderException;
+
+ // ejbHome methods ---------------------------------------------------------
+ public Set ejbHomeSelectBoss_ejbql(String name) throws FinderException {
+ return ejbSelectBoss_ejbql(name.trim());
+ }
+
+ public Set ejbHomeSelectBoss_declaredsql(String name)
+ throws FinderException
+ {
+ return ejbSelectBoss_declaredsql(name.trim().toLowerCase());
+ }
+
+ public Set ejbHomeSelectInStates(Set states) throws FinderException {
+ // generate JBossQL query
+ StringBuffer jbossQl = new StringBuffer();
+ jbossQl.append("SELECT OBJECT(g) ");
+ jbossQl.append("FROM gangster g ");
+ jbossQl.append("WHERE g.hangout.state IN (");
+ for(int i = 0; i < states.size(); i++) {
+ if(i > 0) {
+ jbossQl.append(", ");
+ }
+ jbossQl.append("?").append(i+1);
+ }
+ jbossQl.append(") ORDER BY g.name");
+
+ // pack arguments into an Object[]
+ Object[] args = states.toArray(new Object[states.size()]);
+
+ // call dynamic-ql query
+ return ejbSelectGeneric(jbossQl.toString(), args);
+ }
+
+ // EJB callbacks -----------------------------------------------------------
+ public void setEntityContext(EntityContext context)
+ {
+ ctx = context;
+ }
+
+ public void unsetEntityContext()
+ {
+ ctx = null;
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ log.info("Removing " + getName());
+ }
+
+ public void ejbStore()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/GangsterHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,39 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import java.util.Set;
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+public interface GangsterHome
+ extends EJBLocalHome
+{
+ Gangster create(Integer id, String name, String nickName)
+ throws CreateException;
+ Gangster create(Integer id,
+ String name,
+ String nickName,
+ int badness,
+ Organization org)
+ throws CreateException;
+
+ Gangster findByPrimaryKey(Integer id) throws FinderException;
+
+ Collection findAll() throws FinderException;
+ Collection findAll_none() throws FinderException;
+ Collection findAll_onfind() throws FinderException;
+ Collection findAll_onload() throws FinderException;
+
+ Collection findBadDudes_ejbql(int badness) throws FinderException;
+ Collection findBadDudes_jbossql(int badness) throws FinderException;
+ Collection findBadDudes_declaredsql(int badness) throws FinderException;
+
+ Set selectBoss_ejbql(String name) throws FinderException;
+ Set selectBoss_declaredsql(String name) throws FinderException;
+
+ Set selectInStates(Set states) throws FinderException;
+
+ /** Finds just four gangsters. Used in read ahead tests. */
+ Collection findFour() throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Job.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Job.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Job.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,17 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Set;
+import javax.ejb.EJBLocalObject;
+
+public interface Job extends EJBLocalObject
+{
+ String getName();
+
+ double getScore();
+ void setScore(double score);
+
+ double getSetupCost();
+ void setSetupCost(double setupCost);
+
+ Set getGangsters();
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,74 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Set;
+import javax.ejb.CreateException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import org.apache.log4j.Category;
+
+public abstract class JobBean implements EntityBean
+{
+ private EntityContext ctx;
+ private Category log = Category.getInstance(getClass());
+
+ public String ejbCreate(String name)
+ throws CreateException
+ {
+ log.info("Creating Job " + name);
+ setName(name);
+ return null;
+ }
+
+ public void ejbPostCreate(String name)
+ {
+ }
+
+ // CMP field accessors -----------------------------------------------------
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract double getScore();
+ public abstract void setScore(double param);
+
+
+ public abstract double getSetupCost();
+ public abstract void setSetupCost(double setupCost);
+
+ // CMR field accessors -----------------------------------------------------
+ public abstract Set getGangsters();
+ public abstract void setGangsters(Set gangsters);
+
+ // EJB callbacks -----------------------------------------------------------
+ public void setEntityContext(EntityContext context)
+ {
+ ctx = context;
+ }
+
+ public void unsetEntityContext()
+ {
+ ctx = null;
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ log.info("Removing " + getName());
+ }
+
+ public void ejbStore()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/JobHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,15 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+public interface JobHome extends EJBLocalHome
+{
+ Job create(String name) throws CreateException;
+
+ Job findByPrimaryKey(String name) throws FinderException;
+
+ Collection findAll() throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Location.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Location.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Location.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,72 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.ejb.EJBLocalObject;
+
+public interface Location extends EJBLocalObject
+{
+ public abstract Integer getLocationID();
+
+ /**
+ * Gets the address description.
+ * @return description of the address
+ */
+ public abstract String getDescription();
+
+ /**
+ * Sets the address description.
+ * @param description new address description
+ */
+ public abstract void setDescription(String description);
+
+ /**
+ * Gets the address street.
+ * @return street of the address
+ */
+ public abstract String getStreet();
+
+ /**
+ * Sets the address street.
+ * @param street new address street
+ */
+ public abstract void setStreet(String street);
+
+ /**
+ * Gets the city of the address.
+ * @return city of the address
+ */
+ String getCity();
+
+ /**
+ * Sets the city for the address.
+ * @param city the new city for the address
+ */
+ void setCity(String city);
+
+ /**
+ * Gets the two letter state code for the address.
+ * @return the two letter state code
+ */
+ String getState();
+
+ /**
+ * Sets the two letter state code for the address.
+ * @param state the new two letter state code for the address
+ * @throws IllegalArgumentException if the state does not contain
+ * exactally two letters
+ */
+ void setState(String state);
+
+ /**
+ * Gets the zip code of the address.
+ * @return the address zip code
+ */
+ int getZipCode();
+
+ /**
+ * Sets the zip code of the address.
+ * @param zipCode the new zip code for the address
+ * @throws IllegalArgumentException if the zip code is a negative number
+ * or if the zipCode has more then five digits.
+ */
+ void setZipCode(int zipCode);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,140 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.ejb.CreateException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+
+import org.apache.log4j.Category;
+
+public abstract class LocationBean implements EntityBean
+{
+ private EntityContext ctx;
+ private Category log = Category.getInstance(getClass());
+
+ public Integer ejbCreate() throws CreateException
+ {
+ return null;
+ }
+
+ public void ejbPostCreate()
+ {
+ Object id = ctx.getPrimaryKey();
+ log.debug("ejbPostCreate, id="+id);
+ }
+
+ public Integer ejbCreate(String description, String street, String city,
+ String state, int zipCode) throws CreateException
+ {
+ setDescription(description);
+ setStreet(street);
+ setCity(city);
+ setState(state);
+ setZipCode(zipCode);
+ return null;
+ }
+
+ public void ejbPostCreate(String description, String street, String city,
+ String state, int zipCode) throws CreateException
+ {
+ Object id = ctx.getPrimaryKey();
+ log.debug("ejbPostCreate, id="+id);
+ }
+
+ public abstract Integer getLocationID();
+ public abstract void setLocationID(Integer id);
+
+ /**
+ * Gets the address description.
+ * @return description of the address
+ */
+ public abstract String getDescription();
+
+ /**
+ * Sets the address description.
+ * @param description new address description
+ */
+ public abstract void setDescription(String description);
+
+ /**
+ * Gets the address street.
+ * @return street of the address
+ */
+ public abstract String getStreet();
+
+ /**
+ * Sets the address street.
+ * @param street new address street
+ */
+ public abstract void setStreet(String street);
+
+ /**
+ * Gets the city of the address.
+ * @return city of the address
+ */
+ public abstract String getCity();
+
+ /**
+ * Sets the city for the address.
+ * @param city the new city for the address
+ */
+ public abstract void setCity(String city);
+
+ /**
+ * Gets the two letter state code for the address.
+ * @return the two letter state code
+ */
+ public abstract String getState();
+
+ /**
+ * Sets the two letter state code for the address.
+ * @param state the new two letter state code for the address
+ * @throws IllegalArgumentException if the state does not contain
+ * exactally two letters
+ */
+ public abstract void setState(String state);
+
+ /**
+ * Gets the zip code of the address.
+ * @return the address zip code
+ */
+ public abstract int getZipCode();
+
+ /**
+ * Sets the zip code of the address.
+ * @param zipCode the new zip code for the address
+ * @throws IllegalArgumentException if the zip code is a negative number
+ * or if the zipCode has more then five digits.
+ */
+ public abstract void setZipCode(int zipCode);
+
+ // EJB callbacks -----------------------------------------------------------
+ public void setEntityContext(EntityContext context)
+ {
+ ctx = context;
+ }
+
+ public void unsetEntityContext()
+ {
+ ctx = null;
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+
+ public void ejbStore()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/LocationHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,18 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+public interface LocationHome extends EJBLocalHome
+{
+ Location create() throws CreateException;
+
+ Location create(String description, String streep, String city,
+ String state, int zipCode) throws CreateException;
+
+ Location findByPrimaryKey(Integer pk) throws FinderException;
+
+ Collection findAll() throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Organization.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Organization.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/Organization.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,18 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Set;
+import javax.ejb.EJBLocalObject;
+
+public interface Organization extends javax.ejb.EJBLocalObject
+{
+
+ String getName();
+
+ String getDescription();
+ void setDescription(String description);
+
+ Set getMemberGangsters();
+
+ Gangster getTheBoss();
+ void setTheBoss(Gangster theBoss);
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,85 @@
+package org.jboss.cmp2.crimeportal;
+
+import org.apache.log4j.Category;
+import java.util.Collection;
+import java.util.Set;
+import javax.ejb.CreateException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.FinderException;
+
+public abstract class OrganizationBean implements EntityBean
+{
+ private Category log = Category.getInstance(getClass());
+ private EntityContext ctx;
+
+ public String ejbCreate(String name, String description)
+ throws CreateException
+ {
+ log.info("Creating organization " + name + ", " + description);
+ setName(name);
+ setDescription(description);
+ return null;
+ }
+
+ public void ejbPostCreate(String name, String description)
+ {
+ }
+
+ // CMP Field Accessors -----------------------------------------------------
+ public abstract String getName();
+ public abstract void setName(String param);
+
+ public abstract String getDescription();
+ public abstract void setDescription(String param);
+
+ // CMR Field Accessors -----------------------------------------------------
+ public abstract Set getMemberGangsters();
+ public abstract void setMemberGangsters(Set gangsters);
+
+ public abstract Gangster getTheBoss();
+ public abstract void setTheBoss(Gangster theBoss);
+
+ // ejbSelect methods -------------------------------------------------------
+ public abstract Collection ejbSelectOperatingZipCodes_declaredsql(
+ String name) throws FinderException;
+
+ // ejbHome methods ---------------------------------------------------------
+ public Collection ejbHomeSelectOperatingZipCodes_declaredsql(String name)
+ throws FinderException {
+
+ return ejbSelectOperatingZipCodes_declaredsql(name.trim().toLowerCase());
+ }
+
+ // EJB callbacks -----------------------------------------------------------
+ public void setEntityContext(EntityContext context)
+ {
+ ctx = context;
+ }
+
+ public void unsetEntityContext()
+ {
+ ctx = null;
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ log.info("Removing " + getName());
+ }
+
+ public void ejbStore()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/OrganizationHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,21 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import java.util.Set;
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+public interface OrganizationHome extends javax.ejb.EJBLocalHome
+{
+
+ Organization create(String name, String description)
+ throws CreateException;
+
+ Collection findAll() throws FinderException;
+
+ Organization findByPrimaryKey(String pk) throws FinderException;
+
+ Collection selectOperatingZipCodes_declaredsql(String name)
+ throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/PhoneNumber.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/PhoneNumber.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/PhoneNumber.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,169 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.io.Serializable;
+
+/**
+ * PhoneNumber contains a US phone number broken into three seperate number;
+ * area code, exchange, and extension.
+ */
+public class PhoneNumber
+ implements Serializable
+{
+ /** The first three digits of the phone number. */
+ private short areaCode;
+
+ /** The middle three digits of the phone number. */
+ private short exchange;
+
+ /** The last four digits of the phone number. */
+ private short extension;
+
+ /**
+ * Creates the phone number (000) 000-0000.
+ */
+ public PhoneNumber() {
+ }
+
+ /**
+ * Creates a phone number with the specified areaCode, exchange, and
+ * extension.
+ * @param areaCode the first three digits of the phone number
+ * @param exchange the middle three digits of the phone number
+ * @param extension the last four digits of the phone number
+ * @throws IllegalArgumentException if any of the numbers is negative, if
+ * the area code or excange have more then three digits, or if the extension
+ * has more then four digits.
+ */
+ public PhoneNumber(int areaCode, int exchange, int extension) {
+ setAreaCode((short)areaCode);
+ setExchange((short)exchange);
+ setExtension((short)extension);
+ }
+
+ /**
+ * Gets the area code, which is the first three digits of the phone number.
+ * @return the first three digits of the phone number
+ */
+ public short getAreaCode() {
+ return areaCode;
+ }
+
+ /**
+ * Sets the area code, which is the first three digits of the phone number.
+ * @param areaCode the first three digits of the phone number
+ * @throws IllegalArgumentException if the area code is a negative number
+ * or if the area code has more then three digits.
+ */
+ public void setAreaCode(short areaCode) {
+ if (areaCode < 0 || areaCode > 999) {
+ throw new IllegalArgumentException("area code: " + areaCode);
+ }
+ this.areaCode = areaCode;
+ }
+
+ /**
+ * Gets the exchange, which is middle three digits of the phone number.
+ * @return the middle three digits of the phone number
+ */
+ public short getExchange() {
+ return exchange;
+ }
+
+ /**
+ * Sets the exchange, which is middle three digits of the phone number.
+ * @param exchange the middle three digits of the phone number
+ * @throws IllegalArgumentException if the exchange is a negative number
+ * or if the exchange has more then three digits.
+ */
+ public void setExchange(short exchange) {
+ if (exchange < 0 || exchange > 999) {
+ throw new IllegalArgumentException("exchange: " + exchange);
+ }
+ this.exchange = exchange;
+ }
+
+ /**
+ * Gets the extension, which is the last four digits of the phone number.
+ * @return the last four digits of the phone number
+ */
+ public short getExtension() {
+ return extension;
+ }
+
+ /**
+ * Sets the extension, which is the last four digits of the phone number.
+ * @param extension the last four digits of the phone number
+ * @throws IllegalArgumentException if the extension is a negative number
+ * or if the extension has more then four digits.
+ */
+ public void setExtension(short extension) {
+ if (extension < 0 || extension > 9999) {
+ throw new IllegalArgumentException("extension: " + extension);
+ }
+ this.extension = extension;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (!(o instanceof PhoneNumber)) {
+ return false;
+ }
+ PhoneNumber phoneNumber = (PhoneNumber)o;
+ return phoneNumber.extension == this.extension &&
+ phoneNumber.exchange == this.exchange &&
+ phoneNumber.areaCode == this.areaCode;
+ }
+
+ public int hashCode() {
+ int result = 17;
+ result = 37 * result + areaCode;
+ result = 37 * result + exchange;
+ result = 37 * result + extension;
+ return result;
+ }
+
+ /**
+ * Returns the string representation of this phone number.
+ * The string consists of fourteen characters whose format
+ * is "(XXX) YYY-ZZZZ", where XXX is the area code, YYY is
+ * the extension, and ZZZZ is the exchange. (Each of the
+ * capital letters represents a single decimal digit.)
+ *
+ * If any of the three parts of this phone number is too small
+ * to fill up its field, the field is padded with leading zeros.
+ * For example, if the value of the exchange is 123, the last
+ * four characters of the string representation will be "0123".
+ *
+ * Note that there is a single space separating the closing
+ * parenthesis after the area code from the first digit of the
+ * exchange.
+ */
+ public String toString() {
+ return "(" + toPaddedString(areaCode, 3) + ") " +
+ toPaddedString(exchange, 3) + "-" +
+ toPaddedString(extension, 4);
+ }
+
+ /**
+ * Converts the number to a string padded with zeros on
+ * the lefthand side to be atleas the specified length.
+ * Used by toString.
+ * @param number the number to convert to a string
+ * @param length minimum length of the converted number
+ * @return the number as a string of length atleas the length specified. if
+ * the number is not long enough, zeros are padded to the left hand side.
+ */
+ private static String toPaddedString(int number, int length) {
+ String s = Integer.toString(number);
+ return ZEROS[length - s.length()] + s;
+ }
+
+ /**
+ * Helper array of strings of zeros. Used by toPaddedString.
+ */
+ private static String[] ZEROS =
+ {"", "0", "00", "000", "0000", "00000",
+ "000000", "0000000", "00000000", "000000000"};
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAhead.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAhead.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAhead.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.ejb.EJBLocalObject;
+import javax.ejb.FinderException;
+
+public interface ReadAhead extends EJBLocalObject
+{
+ String createGangsterHtmlTable_none() throws FinderException;
+ String createGangsterHtmlTable_onload() throws FinderException;
+ String createGangsterHtmlTable_onfind() throws FinderException;
+ String createGangsterHangoutHtmlTable() throws FinderException;
+ String createGangsterHtmlTable_no_tx() throws FinderException;
+ String createGangsterHtmlTable_with_tx() throws FinderException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,204 @@
+package org.jboss.cmp2.crimeportal;
+
+import java.util.Collection;
+import java.util.Iterator;
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.ejb.EJBException;
+import javax.ejb.FinderException;
+import javax.naming.InitialContext;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+import org.apache.log4j.Category;
+
+public class ReadAheadBean implements SessionBean
+{
+ private SessionContext ctx;
+ private GangsterHome gangsterHome;
+
+ public void ejbCreate() throws CreateException
+ {
+ try
+ {
+ InitialContext jndi = new InitialContext();
+ gangsterHome = (GangsterHome) jndi.lookup("crimeportal/Gangster");
+ }
+ catch (Exception e)
+ {
+ throw new CreateException("Error while looking up GangsterHome");
+ }
+ }
+
+ public String createGangsterHtmlTable_none() throws FinderException
+ {
+ StringBuffer table = new StringBuffer();
+ table.append("<table>");
+
+ Collection gangsters = gangsterHome.findAll_none();
+ for (Iterator iter = gangsters.iterator(); iter.hasNext();)
+ {
+ Gangster gangster = (Gangster) iter.next();
+ table.append("<tr>");
+ table.append("<td>").append(gangster.getName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getNickName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getBadness());
+ table.append("</td>");
+ table.append("</tr>");
+ }
+
+ table.append("</table>");
+ return table.toString();
+ }
+
+ public String createGangsterHtmlTable_onfind() throws FinderException
+ {
+ StringBuffer table = new StringBuffer();
+ table.append("<table>");
+
+ Collection gangsters = gangsterHome.findAll_onfind();
+ for (Iterator iter = gangsters.iterator(); iter.hasNext();)
+ {
+ Gangster gangster = (Gangster) iter.next();
+ table.append("<tr>");
+ table.append("<td>").append(gangster.getName()).append("</td>");
+ table.append("<td>").append(gangster.getNickName()).append("</td>");
+ table.append("<td>").append(gangster.getBadness()).append("</td>");
+ table.append("</tr>");
+ }
+
+ table.append("</table>");
+ return table.toString();
+ }
+
+ public String createGangsterHtmlTable_onload() throws FinderException
+ {
+ StringBuffer table = new StringBuffer();
+ table.append("<table>");
+
+ Collection gangsters = gangsterHome.findAll_onload();
+ for (Iterator iter = gangsters.iterator(); iter.hasNext();)
+ {
+ Gangster gangster = (Gangster) iter.next();
+ table.append("<tr>");
+ table.append("<td>").append(gangster.getName()).append("</td>");
+ table.append("<td>").append(gangster.getNickName()).append("</td>");
+ table.append("<td>").append(gangster.getBadness()).append("</td>");
+ table.append("</tr>");
+ }
+
+ table.append("</table>");
+ return table.toString();
+ }
+
+ public String createGangsterHangoutHtmlTable() throws FinderException
+ {
+ StringBuffer table = new StringBuffer();
+ table.append("<table>");
+
+ Collection gangsters = gangsterHome.findAll_onfind();
+ for (Iterator iter = gangsters.iterator(); iter.hasNext();)
+ {
+ Gangster gangster = (Gangster) iter.next();
+ Location hangout = gangster.getHangout();
+ table.append("<tr>");
+ table.append("<td>").append(gangster.getName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getNickName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getBadness());
+ table.append("</td>");
+ table.append("<td>").append(hangout.getCity());
+ table.append("</td>");
+ table.append("<td>").append(hangout.getState());
+ table.append("</td>");
+ table.append("<td>").append(hangout.getZipCode());
+ table.append("</td>");
+ table.append("</tr>");
+ }
+ table.append("</table>");
+ return table.toString();
+ }
+
+ public String createGangsterHtmlTable_no_tx() throws FinderException
+ {
+ StringBuffer table = new StringBuffer();
+ table.append("<table>");
+
+ Collection gangsters = gangsterHome.findFour();
+ for (Iterator iter = gangsters.iterator(); iter.hasNext();)
+ {
+ Gangster gangster = (Gangster) iter.next();
+ table.append("<tr>");
+ table.append("<td>").append(gangster.getName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getNickName());
+ table.append("</td>");
+ table.append("<td>").append(gangster.getBadness());
+ table.append("</td>");
+ table.append("</tr>");
+ }
+
+ table.append("</table>");
+ return table.toString();
+ }
+
+ public String createGangsterHtmlTable_with_tx() throws FinderException
+ {
+ UserTransaction tx = null;
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ tx = (UserTransaction) ctx.lookup("UserTransaction");
+ tx.begin();
+
+ String table = createGangsterHtmlTable_no_tx();
+
+ if (tx.getStatus() == Status.STATUS_ACTIVE)
+ {
+ tx.commit();
+ }
+ return table;
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ if (tx != null) tx.rollback();
+ }
+ catch (SystemException unused)
+ {
+ // eat the exception we are exceptioning out anyway
+ }
+ if (e instanceof FinderException)
+ {
+ throw (FinderException) e;
+ }
+ if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException) e;
+ }
+ throw new EJBException(e);
+ }
+ }
+
+ public void setSessionContext(SessionContext ctx)
+ {
+ ctx = ctx;
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,9 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.ejb.EJBLocalHome;
+import javax.ejb.CreateException;
+
+public interface ReadAheadHome extends EJBLocalHome
+{
+ ReadAhead create() throws CreateException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadTest.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadTest.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/crimeportal/ReadAheadTest.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,109 @@
+package org.jboss.cmp2.crimeportal;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.log4j.Category;
+import org.jboss.test.util.ejb.EJBTestCase;
+
+
+public class ReadAheadTest extends EJBTestCase {
+ public static Test suite() {
+ TestSuite testSuite = new TestSuite("ReadAheadTest");
+ testSuite.addTestSuite(ReadAheadTest.class);
+ return testSuite;
+ }
+
+ public ReadAheadTest(String name) {
+ super(name);
+ }
+
+ private Category log = Category.getInstance(getClass());
+ private ReadAheadHome readAheadHome;
+
+ /**
+ * Looks up all of the home interfaces and creates the initial data.
+ * Looking up objects in JNDI is expensive, so it should be done once
+ * and cached.
+ * @throws Exception if a problem occures while finding the home interfaces,
+ * or if an problem occures while createing the initial data
+ */
+ public void setUp() throws Exception {
+ InitialContext jndi = new InitialContext();
+
+ readAheadHome =
+ (ReadAheadHome) jndi.lookup("crimeportal/ReadAhead");
+ }
+
+ public void testReadAhead_none() throws Exception {
+ ReadAhead readAhead = null;
+ try {
+ readAhead = readAheadHome.create();
+ log.info(
+ "\n\n########################################################" +
+ "\n### read-ahead none" +
+ "\n###");
+
+ readAhead.createGangsterHtmlTable_none();
+
+ log.info(
+ "\n###" +
+ "\n########################################################" +
+ "\n\n" +
+ "\n########################################################" +
+ "\n### read-ahead on-load" +
+ "\n###");
+
+ readAhead.createGangsterHtmlTable_onload();
+
+ log.info(
+ "\n###" +
+ "\n########################################################" +
+ "\n\n" +
+ "\n########################################################" +
+ "\n### read-ahead on-find" +
+ "\n###");
+
+ readAhead.createGangsterHtmlTable_onfind();
+
+ log.info(
+ "\n###" +
+ "\n########################################################" +
+ "\n\n" +
+ "\n########################################################" +
+ "\n### lazy-load relationship" +
+ "\n###");
+
+ readAhead.createGangsterHangoutHtmlTable();
+
+ log.info(
+ "\n###" +
+ "\n########################################################" +
+ "\n\n" +
+ "\n########################################################" +
+ "\n### read-ahead no transaction" +
+ "\n###");
+
+ readAhead.createGangsterHtmlTable_no_tx();
+
+ log.info(
+ "\n###" +
+ "\n########################################################" +
+ "\n\n" +
+ "\n########################################################" +
+ "\n### read-ahead with user transaction" +
+ "\n###");
+
+ readAhead.createGangsterHtmlTable_with_tx();
+
+ log.info(
+ "\n###" +
+ "\n########################################################");
+ } finally {
+ if(readAhead != null) {
+ readAhead.remove();
+ }
+ }
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,400 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
+ <display-name>Crime Portal</display-name>
+ <enterprise-beans>
+ <session>
+ <description>JUnit Session Bean Test Runner</description>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
+ <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
+ <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+ <session>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <local-home>org.jboss.cmp2.crimeportal.ReadAheadHome</local-home>
+ <local>org.jboss.cmp2.crimeportal.ReadAhead</local>
+ <ejb-class>org.jboss.cmp2.crimeportal.ReadAheadBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ <entity>
+ <display-name>Organization Entity Bean</display-name>
+ <ejb-name>OrganizationEJB</ejb-name>
+ <local-home>org.jboss.cmp2.crimeportal.OrganizationHome</local-home>
+ <local>org.jboss.cmp2.crimeportal.Organization</local>
+ <ejb-class>org.jboss.cmp2.crimeportal.OrganizationBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.String</prim-key-class>
+ <reentrant>False</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>organization</abstract-schema-name>
+ <cmp-field>
+ <field-name>name</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>description</field-name>
+ </cmp-field>
+ <primkey-field>name</primkey-field>
+ <query>
+ <query-method>
+ <method-name>ejbSelectOperatingZipCodes_declaredsql</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ </entity>
+ <entity>
+ <display-name>Gangster Entity Bean</display-name>
+ <ejb-name>GangsterEJB</ejb-name>
+ <local-home>org.jboss.cmp2.crimeportal.GangsterHome</local-home>
+ <local>org.jboss.cmp2.crimeportal.Gangster</local>
+ <ejb-class>org.jboss.cmp2.crimeportal.GangsterBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>False</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>gangster</abstract-schema-name>
+ <cmp-field>
+ <field-name>gangsterId</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>name</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>nickName</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>badness</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>contactInfo</field-name>
+ </cmp-field>
+ <primkey-field>gangsterId</primkey-field>
+ <query>
+ <query-method>
+ <method-name>findBadDudes_ejbql</method-name>
+ <method-params>
+ <method-param>int</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ WHERE g.badness > ?1
+ ]]></ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findBadDudes_jbossql</method-name>
+ <method-params>
+ <method-param>int</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findBadDudes_declaredsql</method-name>
+ <method-params>
+ <method-param>int</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>ejbSelectBoss_ejbql</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql><![CDATA[
+ SELECT DISTINCT underling.organization.theBoss
+ FROM gangster underling
+ WHERE underling.name = ?1 OR underling.nickName = ?1
+ ]]></ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>ejbSelectBoss_declaredsql</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>ejbSelectAccomplices</method-name>
+ <method-params>
+ <method-param>org.jboss.cmp2.crimeportal.Gangster</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql><![CDATA[
+ SELECT DISTINCT OBJECT(g)
+ FROM gangster g, IN(g.jobs) j, IN(j.gangsters) accomplice
+ WHERE g = ?1 AND accomplice <> ?1
+ ]]></ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>ejbSelectGeneric</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ <method-param>java.lang.Object[]</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll_none</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll_onfind</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll_onload</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findFour</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql/>
+ </query>
+ </entity>
+ <entity>
+ <display-name>Job Entity Bean</display-name>
+ <ejb-name>JobEJB</ejb-name>
+ <local-home>org.jboss.cmp2.crimeportal.JobHome</local-home>
+ <local>org.jboss.cmp2.crimeportal.Job</local>
+ <ejb-class>org.jboss.cmp2.crimeportal.JobBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.String</prim-key-class>
+ <reentrant>False</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>job</abstract-schema-name>
+ <cmp-field>
+ <field-name>name</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>score</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>setupCost</field-name>
+ </cmp-field>
+ <primkey-field>name</primkey-field>
+ </entity>
+ <entity>
+ <ejb-name>LocationEJB</ejb-name>
+ <local-home>org.jboss.cmp2.crimeportal.LocationHome</local-home>
+ <local>org.jboss.cmp2.crimeportal.Location</local>
+ <ejb-class>org.jboss.cmp2.crimeportal.LocationBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>False</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>location</abstract-schema-name>
+ <cmp-field>
+ <field-name>locationID</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>description</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>street</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>city</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>state</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>zipCode</field-name>
+ </cmp-field>
+ <primkey-field>locationID</primkey-field>
+ </entity>
+ </enterprise-beans>
+ <relationships>
+ <ejb-relation>
+ <ejb-relation-name>Organization-Gangster</ejb-relation-name>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>org-has-gangsters</ejb-relationship-role-name>
+ <multiplicity>One</multiplicity>
+ <relationship-role-source>
+ <ejb-name>OrganizationEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>memberGangsters</cmr-field-name>
+ <cmr-field-type>java.util.Set</cmr-field-type>
+ </cmr-field>
+ </ejb-relationship-role>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-belongs-to-org</ejb-relationship-role-name>
+ <multiplicity>Many</multiplicity>
+ <cascade-delete/>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>organization</cmr-field-name>
+ </cmr-field>
+ </ejb-relationship-role>
+ </ejb-relation>
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Jobs</ejb-relation-name>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-jobs</ejb-relationship-role-name>
+ <multiplicity>Many</multiplicity>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>jobs</cmr-field-name>
+ <cmr-field-type>java.util.Set</cmr-field-type>
+ </cmr-field>
+ </ejb-relationship-role>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>job-has-gangsters</ejb-relationship-role-name>
+ <multiplicity>Many</multiplicity>
+ <relationship-role-source>
+ <ejb-name>JobEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>gangsters</cmr-field-name>
+ <cmr-field-type>java.util.Set</cmr-field-type>
+ </cmr-field>
+ </ejb-relationship-role>
+ </ejb-relation>
+ <ejb-relation>
+ <ejb-relation-name>Organization-Boss</ejb-relation-name>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>organization-has-a-boss</ejb-relationship-role-name>
+ <multiplicity>One</multiplicity>
+ <relationship-role-source>
+ <ejb-name>OrganizationEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>theBoss</cmr-field-name>
+ </cmr-field>
+ </ejb-relationship-role>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>boss-runs-an-organization</ejb-relationship-role-name>
+ <multiplicity>One</multiplicity>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ </ejb-relationship-role>
+ </ejb-relation>
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Enemies</ejb-relation-name>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-enemies</ejb-relationship-role-name>
+ <multiplicity>Many</multiplicity>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>enemies</cmr-field-name>
+ <cmr-field-type>java.util.Set</cmr-field-type>
+ </cmr-field>
+ </ejb-relationship-role>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>enemy-to-gangsters</ejb-relationship-role-name>
+ <multiplicity>Many</multiplicity>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ </ejb-relationship-role>
+ </ejb-relation>
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Hangout</ejb-relation-name>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-a-hangout</ejb-relationship-role-name>
+ <multiplicity>One</multiplicity>
+ <relationship-role-source>
+ <ejb-name>GangsterEJB</ejb-name>
+ </relationship-role-source>
+ <cmr-field>
+ <cmr-field-name>hangout</cmr-field-name>
+ </cmr-field>
+ </ejb-relationship-role>
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>hangout-for-a-gangster</ejb-relationship-role-name>
+ <multiplicity>One</multiplicity>
+ <relationship-role-source>
+ <ejb-name>LocationEJB</ejb-name>
+ </relationship-role-source>
+ </ejb-relationship-role>
+ </ejb-relation>
+ </relationships>
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>OrganizationEJB</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <method>
+ <ejb-name>GangsterEJB</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <method>
+ <ejb-name>JobEJB</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <method>
+ <ejb-name>LocationEJB</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ <container-transaction>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHtmlTable_none</method-name>
+ </method>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHtmlTable_onload</method-name>
+ </method>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHtmlTable_onfind</method-name>
+ </method>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHangoutHtmlTable</method-name>
+ </method>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </container-transaction>
+ <container-transaction>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHtmlTable_no_tx</method-name>
+ </method>
+ <method>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <method-name>createGangsterHtmlTable_with_tx</method-name>
+ </method>
+ <trans-attribute>NotSupported</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss PUBLIC
+ "-//JBoss//DTD JBOSS 3.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
+
+
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <jndi-name>ejb/EJBTestRunner</jndi-name>
+ </session>
+ <session>
+ <ejb-name>ReadAheadEJB</ejb-name>
+ <local-jndi-name>crimeportal/ReadAhead</local-jndi-name>
+ </session>
+ <entity>
+ <ejb-name>OrganizationEJB</ejb-name>
+ <local-jndi-name>crimeportal/Organization</local-jndi-name>
+ </entity>
+ <entity>
+ <ejb-name>GangsterEJB</ejb-name>
+ <local-jndi-name>crimeportal/Gangster</local-jndi-name>
+ </entity>
+ <entity>
+ <ejb-name>JobEJB</ejb-name>
+ <local-jndi-name>crimeportal/Job</local-jndi-name>
+ </entity>
+ <entity>
+ <ejb-name>LocationEJB</ejb-name>
+ <local-jndi-name>crimeportal/Location</local-jndi-name>
+ </entity>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jbosscmp-jdbc.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jbosscmp-jdbc.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/cmp2/jbosscmp-jdbc.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,508 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
+
+<jbosscmp-jdbc>
+ <defaults>
+ <datasource>java:/DefaultDS</datasource>
+ <datasource-mapping>Hypersonic SQL</datasource-mapping>
+ <create-table>true</create-table>
+ <remove-table>true</remove-table>
+ <pk-constraint>true</pk-constraint>
+ <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
+ </defaults>
+
+ <enterprise-beans>
+
+ <entity>
+ <ejb-name>OrganizationEJB</ejb-name>
+ <table-name>organization</table-name>
+
+ <cmp-field>
+ <field-name>name</field-name>
+ <column-name>name</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>description</field-name>
+ <column-name>desc</column-name>
+ <not-null/>
+ </cmp-field>
+ <query>
+ <query-method>
+ <method-name>ejbSelectOperatingZipCodes_declaredsql</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <declared-sql>
+ <select>
+ <distinct/>
+ <ejb-name>LocationEJB</ejb-name>
+ <field-name>zipCode</field-name>
+ <alias>hangout</alias>
+ </select>
+ <from><![CDATA[ , organization o, gangster g ]]></from>
+ <where><![CDATA[
+ LCASE(o.name) = {0} AND o.name = g.organization AND
+ g.hangout = hangout.id
+ ]]></where>
+ <order><![CDATA[ hangout.zip ]]></order>
+ </declared-sql>
+ </query>
+ </entity>
+
+ <entity>
+ <ejb-name>GangsterEJB</ejb-name>
+ <table-name>gangster</table-name>
+
+ <cmp-field>
+ <field-name>gangsterId</field-name>
+ <column-name>id</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>name</field-name>
+ <column-name>name</column-name>
+ <not-null/>
+ </cmp-field>
+ <cmp-field>
+ <field-name>nickName</field-name>
+ <column-name>nick_name</column-name>
+ <jdbc-type>VARCHAR</jdbc-type>
+ <sql-type>VARCHAR(64)</sql-type>
+ </cmp-field>
+ <cmp-field>
+ <field-name>badness</field-name>
+ <column-name>badness</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>contactInfo</field-name>
+ <property>
+ <property-name>cell.areaCode</property-name>
+ <column-name>cell_area</column-name>
+ </property>
+ <property>
+ <property-name>cell.exchange</property-name>
+ <column-name>cell_exch</column-name>
+ </property>
+ <property>
+ <property-name>cell.extension</property-name>
+ <column-name>cell_ext</column-name>
+ </property>
+
+ <property>
+ <property-name>pager.areaCode</property-name>
+ <column-name>page_area</column-name>
+ </property>
+ <property>
+ <property-name>pager.exchange</property-name>
+ <column-name>page_exch</column-name>
+ </property>
+ <property>
+ <property-name>pager.extension</property-name>
+ <column-name>page_ext</column-name>
+ </property>
+
+ <property>
+ <property-name>email</property-name>
+ <column-name>email</column-name>
+ <jdbc-type>VARCHAR</jdbc-type>
+ <sql-type>VARCHAR(128)</sql-type>
+ </property>
+ </cmp-field>
+
+ <load-groups>
+ <load-group>
+ <load-group-name>basic</load-group-name>
+ <field-name>name</field-name>
+ <field-name>nickName</field-name>
+ <field-name>badness</field-name>
+ </load-group>
+ <load-group>
+ <load-group-name>contact info</load-group-name>
+ <field-name>nickName</field-name>
+ <field-name>contactInfo</field-name>
+ <field-name>hangout</field-name>
+ </load-group>
+
+ <!--
+ This group is used in place of the default star group
+ to make readahead test sql easier to read. It contains
+ all fields except the contactInfo field.
+ -->
+ <load-group>
+ <load-group-name>most</load-group-name>
+ <field-name>name</field-name>
+ <field-name>nickName</field-name>
+ <field-name>badness</field-name>
+ <field-name>hangout</field-name>
+ <field-name>organization</field-name>
+ </load-group>
+ </load-groups>
+
+ <eager-load-group>most</eager-load-group>
+
+ <lazy-load-groups>
+ <load-group-name>basic</load-group-name>
+ <load-group-name>contact info</load-group-name>
+ </lazy-load-groups>
+
+ <query>
+ <query-method>
+ <method-name>findBadDudes_jbossql</method-name>
+ <method-params><method-param>int</method-param></method-params>
+ </query-method>
+ <jboss-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ WHERE g.badness > ?1
+ ORDER BY g.badness DESC
+ ]]></jboss-ql>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>findBadDudes_declaredsql</method-name>
+ <method-params><method-param>int</method-param></method-params>
+ </query-method>
+ <declared-sql>
+ <where><![CDATA[ badness > {0} ]]></where>
+ <order><![CDATA[ badness DESC ]]></order>
+ </declared-sql>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>ejbSelectBoss_declaredsql</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <declared-sql>
+ <select>
+ <distinct/>
+ <ejb-name>GangsterEJB</ejb-name>
+ <alias>boss</alias>
+ </select>
+ <from><![CDATA[, gangster g, organization o]]></from>
+ <where><![CDATA[
+ (LCASE(g.name) = {0} OR LCASE(g.nick_name) = {0}) AND
+ g.organization = o.name AND o.the_boss = boss.id
+ ]]></where>
+ </declared-sql>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>ejbSelectGeneric</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ <method-param>java.lang.Object[]</method-param>
+ </method-params>
+ </query-method>
+ <dynamic-ql/>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>findAll_onfind</method-name>
+ <method-params/>
+ </query-method>
+ <jboss-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ ORDER BY g.gangsterId
+ ]]></jboss-ql>
+ <read-ahead>
+ <strategy>on-find</strategy>
+ <page-size>4</page-size>
+ <eager-load-group>basic</eager-load-group>
+ </read-ahead>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>findAll_onload</method-name>
+ <method-params/>
+ </query-method>
+ <jboss-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ ORDER BY g.gangsterId
+ ]]></jboss-ql>
+ <read-ahead>
+ <strategy>on-load</strategy>
+ <page-size>4</page-size>
+ <eager-load-group>basic</eager-load-group>
+ </read-ahead>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>findAll_none</method-name>
+ <method-params/>
+ </query-method>
+ <jboss-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ ORDER BY g.gangsterId
+ ]]></jboss-ql>
+ <read-ahead>
+ <strategy>none</strategy>
+ </read-ahead>
+ </query>
+
+ <query>
+ <query-method>
+ <method-name>findFour</method-name>
+ <method-params/>
+ </query-method>
+ <jboss-ql><![CDATA[
+ SELECT OBJECT(g)
+ FROM gangster g
+ WHERE g.gangsterId < 4
+ ORDER BY g.gangsterId
+ ]]></jboss-ql>
+ <read-ahead>
+ <strategy>on-find</strategy>
+ <page-size>1000</page-size>
+ <eager-load-group>basic</eager-load-group>
+ </read-ahead>
+ </query>
+ </entity>
+
+ <entity>
+ <ejb-name>JobEJB</ejb-name>
+ <table-name>job</table-name>
+
+ <cmp-field>
+ <field-name>name</field-name>
+ <column-name>name</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>score</field-name>
+ <column-name>score</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>setupCost</field-name>
+ <column-name>setup_cost</column-name>
+ </cmp-field>
+ </entity>
+
+ <entity>
+ <ejb-name>LocationEJB</ejb-name>
+ <pk-constraint>false</pk-constraint>
+ <table-name>location</table-name>
+
+ <cmp-field>
+ <field-name>locationID</field-name>
+ <column-name>id</column-name>
+ <auto-increment/>
+ </cmp-field>
+ <cmp-field>
+ <field-name>description</field-name>
+ <column-name>description</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>street</field-name>
+ <column-name>street</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>city</field-name>
+ <column-name>city</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>state</field-name>
+ <column-name>st</column-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>zipCode</field-name>
+ <column-name>zip</column-name>
+ </cmp-field>
+
+ <load-groups>
+ <load-group>
+ <load-group-name>quick info</load-group-name>
+ <field-name>city</field-name>
+ <field-name>state</field-name>
+ <field-name>zipCode</field-name>
+ </load-group>
+ </load-groups>
+ <eager-load-group/>
+ <!--
+ <unknown-pk>
+ <unknown-pk-class>java.lang.Integer</unknown-pk-class>
+ <field-name>locationID</field-name>
+ <column-name>id</column-name>
+ <jdbc-type>INTEGER</jdbc-type>
+ <sql-type>INTEGER</sql-type>
+ <auto-increment/>
+ </unknown-pk>
+ -->
+ <entity-command name="hsqldb-fetch-key"/>
+
+ </entity>
+ </enterprise-beans>
+
+ <relationships>
+ <ejb-relation>
+ <ejb-relation-name>Organization-Gangster</ejb-relation-name>
+ <foreign-key-mapping/>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>org-has-gangsters</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>name</field-name>
+ <column-name>organization</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-belongs-to-org</ejb-relationship-role-name>
+ <key-fields/>
+ </ejb-relationship-role>
+ </ejb-relation>
+
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Jobs</ejb-relation-name>
+ <relation-table-mapping>
+ <table-name>gangster_job</table-name>
+ </relation-table-mapping>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-jobs</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>gangsterId</field-name>
+ <column-name>gangster</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>job-has-gangsters</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>name</field-name>
+ <column-name>job</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+ </ejb-relation>
+
+ <ejb-relation>
+ <ejb-relation-name>Organization-Boss</ejb-relation-name>
+ <foreign-key-mapping/>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>organization-has-a-boss</ejb-relationship-role-name>
+ <key-fields/>
+ </ejb-relationship-role>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>boss-runs-an-organization</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>gangsterId</field-name>
+ <column-name>the_boss</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+ </ejb-relation>
+
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Enemies</ejb-relation-name>
+ <relation-table-mapping>
+ <table-name>gangster_enemies</table-name>
+ </relation-table-mapping>
+
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-enemies</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>gangsterId</field-name>
+ <column-name>gangster_1</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>enemy-to-gangsters</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>gangsterId</field-name>
+ <column-name>gangster_2</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+ </ejb-relation>
+
+ <ejb-relation>
+ <ejb-relation-name>Gangster-Hangout</ejb-relation-name>
+ <foreign-key-mapping/>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>gangster-has-a-hangout</ejb-relationship-role-name>
+ <key-fields/>
+
+ <read-ahead>
+ <strategy>on-find</strategy>
+ <page-size>4</page-size>
+ <eager-load-group>quick info</eager-load-group>
+ </read-ahead>
+ </ejb-relationship-role>
+
+ <ejb-relationship-role>
+ <ejb-relationship-role-name>hangout-for-a-gangster</ejb-relationship-role-name>
+ <key-fields>
+ <key-field>
+ <field-name>locationID</field-name>
+ <column-name>hangout</column-name>
+ </key-field>
+ </key-fields>
+ </ejb-relationship-role>
+ </ejb-relation>
+ </relationships>
+
+ <dependent-value-classes>
+ <dependent-value-class>
+ <description>A phone number</description>
+ <class>org.jboss.cmp2.crimeportal.PhoneNumber</class>
+ <property>
+ <property-name>areaCode</property-name>
+ <column-name>area_code</column-name>
+ </property>
+ <property>
+ <property-name>exchange</property-name>
+ <column-name>exchange</column-name>
+ </property>
+ <property>
+ <property-name>extension</property-name>
+ <column-name>extension</column-name>
+ </property>
+ </dependent-value-class>
+
+ <dependent-value-class>
+ <description>General contact info</description>
+ <class>org.jboss.cmp2.crimeportal.ContactInfo</class>
+ <property>
+ <property-name>cell</property-name>
+ <column-name>cell</column-name>
+ </property>
+ <property>
+ <property-name>pager</property-name>
+ <column-name>pager</column-name>
+ </property>
+ <property>
+ <property-name>email</property-name>
+ <column-name>email</column-name>
+ <jdbc-type>VARCHAR</jdbc-type>
+ <sql-type>VARCHAR(128)</sql-type>
+ </property>
+ </dependent-value-class>
+ </dependent-value-classes>
+
+
+</jbosscmp-jdbc>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/ex1/ExClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/ex1/ExClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/ex1/ExClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,32 @@
+package org.jboss.naming.ex1;
+
+import java.security.Security;
+import java.util.Properties;
+import java.net.URL;
+import java.net.MalformedURLException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+/** A simple JNDI client that uses HTTPS as the transport.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ExClient
+{
+ public static void main(String args[]) throws Exception
+ {
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jboss.naming.HttpNamingContextFactory");
+ env.setProperty(Context.PROVIDER_URL,
+ "https://localhost:8443/invoker/JNDIFactorySSL");
+
+ Context ctx = new InitialContext(env);
+ System.out.println("Created InitialContext, env=" + env);
+
+ Object data = ctx.lookup("jmx/invoker/RMIAdaptor");
+ System.out.println("lookup(jmx/invoker/RMIAdaptor): " + data);
+ }
+}
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE server>
+<!-- $Id: invoker-service.xml,v 1.1 2006/11/01 18:14:22 nrichards Exp $ -->
+
+<server>
+
+ <!-- The HTTP invoker service configration
+ -->
+ <mbean code="org.jboss.invocation.http.server.HttpInvoker"
+ name="jboss:service=invoker,type=http">
+ <!-- Use a URL of the form http://<hostname>:8080/invoker/EJBInvokerServlet
+ where <hostname> is InetAddress.getHostname value on which the server
+ is running.
+ -->
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/EJBInvokerServlet</attribute>
+ <attribute name="UseHostName">true</attribute>
+ </mbean>
+
+ <!-- Expose the Naming service interface via HTTP -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
+ name="jboss:service=invoker,type=http,target=Naming">
+ <!-- The Naming service we are proxying -->
+ <attribute name="InvokerName">jboss:service=Naming</attribute>
+ <!-- Compose the invoker URL from the cluster node address -->
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/JMXInvokerServlet</attribute>
+ <attribute name="UseHostName">true</attribute>
+ <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ </mbean>
+
+
+
+
+ <!-- Expose the Naming service interface via HTTP -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
+ name="jboss:service=invoker,type=https,target=Naming">
+ <!-- The Naming service we are proxying -->
+ <attribute name="InvokerName">jboss:service=Naming</attribute>
+ <!-- Compose the invoker URL from the cluster node address -->
+ <attribute name="InvokerURLPrefix">https://</attribute>
+ <attribute name="InvokerURLSuffix">:8443/invoker/JMXInvokerServlet</attribute>
+ <attribute name="UseHostName">true</attribute>
+ <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ </mbean>
+
+
+
+ <!-- Expose the Naming service interface via clustered HTTP. This maps
+ to the ReadOnlyJNDIFactory servlet URL
+ -->
+ <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
+ name="jboss:service=invoker,type=http,target=Naming,readonly=true">
+ <attribute name="InvokerName">jboss:service=Naming</attribute>
+ <attribute name="InvokerURLPrefix">http://</attribute>
+ <attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerServlet</attribute>
+ <attribute name="UseHostName">true</attribute>
+ <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ </mbean>
+</server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-web.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-web.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/invoker-web.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<!-- The http-invoker.sar/invoker.war web.xml descriptor
+$Id: invoker-web.xml,v 1.1 2006/11/01 18:14:22 nrichards Exp $
+-->
+<web-app>
+ <filter>
+ <filter-name>ReadOnlyAccessFilter</filter-name>
+ <filter-class>org.jboss.invocation.http.servlet.ReadOnlyAccessFilter</filter-class>
+ <init-param>
+ <param-name>readOnlyContext</param-name>
+ <param-value>readonly</param-value>
+ <description>The top level JNDI context the filter will enforce
+ read-only access on. If specified only Context.lookup operations
+ will be allowed on this context. Another other operations or lookups
+ on any other context will fail. Do not associate this filter with the
+ JMXInvokerServlets if you want unrestricted access.
+ </description>
+ </init-param>
+ <init-param>
+ <param-name>invokerName</param-name>
+ <param-value>jboss:service=Naming</param-value>
+ <description>The JMX ObjectName of the naming service mbean
+ </description>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>ReadOnlyAccessFilter</filter-name>
+ <url-pattern>/readonly/*</url-pattern>
+ </filter-mapping>
+
+<!-- ### Servlets -->
+ <servlet>
+ <servlet-name>EJBInvokerServlet</servlet-name>
+ <description>The EJBInvokerServlet receives posts containing serlized
+ MarshalledInvocation objects that are routed to the EJB invoker given by
+ the invokerName init-param. The return content is a serialized
+ MarshalledValue containg the return value of the inovocation, or any
+ exception that may have been thrown.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.InvokerServlet</servlet-class>
+ <init-param>
+ <param-name>invokerName</param-name>
+ <param-value>jboss:service=invoker,type=http</param-value>
+ <description>The RMI/HTTP EJB compatible invoker</description>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>JMXInvokerServlet</servlet-name>
+ <description>The JMXInvokerServlet receives posts containing serlized
+ MarshalledInvocation objects that are routed to the invoker given by
+ the the MBean whose object name hash is specified by the
+ invocation.getObjectName() value. The return content is a serialized
+ MarshalledValue containg the return value of the inovocation, or any
+ exception that may have been thrown.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.InvokerServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>JNDIFactory</servlet-name>
+ <description>A servlet that exposes the JBoss JNDI Naming service stub
+ through http. The return content is a serialized
+ MarshalledValue containg the org.jnp.interfaces.Naming stub. This
+ configuration handles requests for the standard JNDI naming service.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
+ <init-param>
+ <param-name>namingProxyMBean</param-name>
+ <param-value>jboss:service=invoker,type=http,target=Naming</param-value>
+ </init-param>
+ <init-param>
+ <param-name>proxyAttribute</param-name>
+ <param-value>Proxy</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>JNDIFactorySSL</servlet-name>
+ <description>A servlet that exposes the JBoss JNDI Naming
+ service stub through http. The return content is a serialized
+ MarshalledValue containg the org.jnp.interfaces.Naming
+ stub. This configuration handles requests for the standard
+ JNDI naming service. </description>
+ <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
+ <init-param>
+ <param-name>namingProxyMBean</param-name>
+ <param-value>jboss:service=invoker,type=https,target=Naming</param-value>
+ </init-param>
+ <init-param>
+ <param-name>proxyAttribute</param-name>
+ <param-value>Proxy</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+
+ <servlet>
+ <servlet-name>ReadOnlyJNDIFactory</servlet-name>
+ <description>A servlet that exposes the JBoss JNDI Naming service stub
+ through http, but only for a single read-only context. The return content
+ is a serialized MarshalledValue containg the org.jnp.interfaces.Naming
+ stub.
+ </description>
+ <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
+ <init-param>
+ <param-name>namingProxyMBean</param-name>
+ <param-value>jboss:service=invoker,type=http,target=Naming,readonly=true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>proxyAttribute</param-name>
+ <param-value>Proxy</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+<!-- ### Servlet Mappings -->
+ <servlet-mapping>
+ <servlet-name>JNDIFactory</servlet-name>
+ <url-pattern>/JNDIFactory/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JNDIFactorySSL</servlet-name>
+ <url-pattern>/JNDIFactorySSL/*</url-pattern>
+ </servlet-mapping>
+
+
+
+
+ <!-- A mapping for the NamingFactoryServlet that only allows invocations
+ of lookups under a read-only context. This is enforced by the
+ ReadOnlyAccessFilter
+ -->
+ <servlet-mapping>
+ <servlet-name>ReadOnlyJNDIFactory</servlet-name>
+ <url-pattern>/ReadOnlyJNDIFactory/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>EJBInvokerServlet</servlet-name>
+ <url-pattern>/EJBInvokerServlet/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JMXInvokerServlet</servlet-name>
+ <url-pattern>/JMXInvokerServlet/*</url-pattern>
+ </servlet-mapping>
+ <!-- A mapping for the JMXInvokerServlet that only allows invocations
+ of lookups under a read-only context. This is enforced by the
+ ReadOnlyAccessFilter
+ -->
+ <servlet-mapping>
+ <servlet-name>JMXInvokerServlet</servlet-name>
+ <url-pattern>/readonly/JMXInvokerServlet/*</url-pattern>
+ </servlet-mapping>
+
+ <!-- Alternate mappings that place the servlets under the restricted
+ path to required authentication for access. Remove the unsecure mappings
+ if only authenticated users should be allowed.
+ -->
+ <servlet-mapping>
+ <servlet-name>JNDIFactory</servlet-name>
+ <url-pattern>/restricted/JNDIFactory/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JMXInvokerServlet</servlet-name>
+ <url-pattern>/restricted/JMXInvokerServlet/*</url-pattern>
+ </servlet-mapping>
+
+ <!-- An example security constraint that restricts access to the HTTP invoker
+ to users with the role HttpInvoker Edit the roles to what you want and
+ configure the WEB-INF/jboss-web.xml/security-domain element to reference
+ the security domain you want.
+ -->
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>HttpInvokers</web-resource-name>
+ <description>An example security config that only allows users with the
+ role HttpInvoker to access the HTTP invoker servlets
+ </description>
+ <url-pattern>/restricted/*</url-pattern>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>HttpInvoker</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>JBoss HTTP Invoker</realm-name>
+ </login-config>
+
+ <security-role>
+ <role-name>HttpInvoker</role-name>
+ </security-role>
+</web-app>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/jboss-service.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/jboss-service.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/jboss-service.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,324 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: jboss-service.xml,v 1.1 2006/11/01 18:14:22 nrichards Exp $ -->
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- Load all jars from the JBOSS_DIST/server/<config>/lib directory. This
+ can be restricted to specific jars by specifying them in the archives
+ attribute.
+ -->
+ <classpath codebase="lib" archives="*"/>
+
+ <!-- ==================================================================== -->
+ <!-- Log4j Initialization -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.logging.Log4jService"
+ name="jboss.system:type=Log4jService,service=Logging">
+ <attribute name="ConfigurationURL">resource:log4j.xml</attribute>
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- JBoss RMI Classloader - only install when available -->
+ <!-- ==================================================================== -->
+ <mbean code="org.jboss.util.property.jmx.SystemPropertyClassValue"
+ name="jboss.rmi:type=RMIClassLoader">
+ <attribute name="Property">java.rmi.server.RMIClassLoaderSpi</attribute>
+ <attribute name="ClassName">org.jboss.system.JBossRMIClassLoader</attribute>
+ </mbean>
+
+
+ <!-- ==================================================================== -->
+ <!-- Class Loading -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.web.WebService"
+ name="jboss:service=WebService">
+ <attribute name="Port">8083</attribute>
+ <!-- Should resources and non-EJB classes be downloadable -->
+ <attribute name="DownloadServerClasses">true</attribute>
+ <attribute name="Host">${jboss.bind.address}</attribute>
+ <attribute name="BindAddress">${jboss.bind.address}</attribute>
+ </mbean>
+
+
+ <!-- ==================================================================== -->
+ <!-- JNDI -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.naming.NamingService"
+ name="jboss:service=Naming">
+ <!-- The listening port for the bootstrap JNP service. Set this to -1
+ to run the NamingService without the JNP invoker listening port.
+ -->
+ <attribute name="Port">1099</attribute>
+ <!-- The bootstrap JNP server bind address. This also sets the default
+ RMI service bind address. Empty == all addresses
+ -->
+ <attribute name="BindAddress">${jboss.bind.address}</attribute>
+ <!-- The port of the RMI naming service, 0 == anonymous -->
+ <attribute name="RmiPort">1098</attribute>
+ <!-- The RMI service bind address. Empty == all addresses
+ -->
+ <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
+ </mbean>
+
+ <mbean code="org.jboss.naming.JNDIView" name="jboss:service=JNDIView">
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- Security -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.security.plugins.SecurityConfig"
+ name="jboss.security:name=SecurityConfig">
+ <attribute name="LoginConfig">jboss.security:service=XMLLoginConfig</attribute>
+ </mbean>
+ <mbean code="org.jboss.security.auth.login.XMLLoginConfig"
+ name="jboss.security:service=XMLLoginConfig">
+ <attribute name="ConfigResource">login-config.xml</attribute>
+ </mbean>
+
+ <!-- JAAS security manager and realm mapping -->
+ <mbean code="org.jboss.security.plugins.JaasSecurityManagerService"
+ name="jboss.security:service=JaasSecurityManager">
+ <attribute name="SecurityManagerClassName">
+ org.jboss.security.plugins.JaasSecurityManager
+ </attribute>
+ </mbean>
+
+ <!-- The SSL domain setup -->
+ <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
+ name="Security:name=JaasSecurityDomain,domain=RMI+SSL">
+ <constructor>
+ <arg type="java.lang.String" value="RMI+SSL"/>
+ </constructor>
+ <attribute name="KeyStoreURL">example.keystore</attribute>
+ <attribute name="KeyStorePass">rmi+ssl</attribute>
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- Transactions -->
+ <!-- ==================================================================== -->
+ <!-- The configurable Xid factory. For use with Oracle, set pad to true -->
+ <mbean code="org.jboss.tm.XidFactory"
+ name="jboss:service=XidFactory">
+ <!--attribute name="Pad">true</attribute-->
+ </mbean>
+
+ <!--
+ | The fast in-memory transaction manager.
+ -->
+ <mbean code="org.jboss.tm.TransactionManagerService"
+ name="jboss:service=TransactionManager">
+ <attribute name="TransactionTimeout">300</attribute>
+
+ <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
+ </mbean>
+
+ <!--
+ | UserTransaction support.
+ -->
+ <mbean code="org.jboss.tm.usertx.server.ClientUserTransactionService"
+ name="jboss:service=ClientUserTransaction">
+ <depends>
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
+ name="jboss:service=proxyFactory,target=ClientUserTransactionFactory">
+ <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
+ <attribute name="TargetName">jboss:service=ClientUserTransaction</attribute>
+ <attribute name="JndiName">UserTransactionSessionFactory</attribute>
+ <attribute name="ExportedInterface">org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory</attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ <depends>jboss:service=invoker,type=jrmp</depends>
+ </mbean>
+ </depends>
+ <depends optional-attribute-name="TxProxyName">
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
+ name="jboss:service=proxyFactory,target=ClientUserTransaction">
+ <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
+ <attribute name="TargetName">jboss:service=ClientUserTransaction</attribute>
+ <attribute name="JndiName"></attribute>
+ <attribute name="ExportedInterface">org.jboss.tm.usertx.interfaces.UserTransactionSession</attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ <depends>jboss:service=invoker,type=jrmp</depends>
+ </mbean>
+ </depends>
+
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- Invokers to the JMX node -->
+ <!-- ==================================================================== -->
+
+ <!-- RMI/JRMP invoker -->
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"
+ name="jboss:service=invoker,type=jrmp">
+ <attribute name="RMIObjectPort">4444</attribute>
+ <attribute name="ServerAddress">${jboss.bind.address}</attribute>
+ <!--
+ <attribute name="RMIClientSocketFactory">custom</attribute>
+ <attribute name="RMIServerSocketFactory">custom</attribute>
+ <attribute name="SecurityDomain">ssl-domain-name</attribute>
+ -->
+ <depends>jboss:service=TransactionManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.invocation.local.LocalInvoker"
+ name="jboss:service=invoker,type=local">
+
+ <depends>jboss:service=TransactionManager</depends>
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- The deployers... -->
+ <!-- ==================================================================== -->
+
+ <!-- EJB deployer, remove to disable EJB behavior-->
+ <mbean code="org.jboss.ejb.EJBDeployer" name="jboss.ejb:service=EJBDeployer">
+ <attribute name="VerifyDeployments">true</attribute>
+ <attribute name="ValidateDTDs">false</attribute>
+ <attribute name="MetricsEnabled">false</attribute>
+ <attribute name="VerifierVerbose">true</attribute>
+
+ <!--
+ StrictVerifier: Setting this to 'true' will cause all deployments
+ to fail when the Verifier detected a problem with the contained
+ Beans.
+ -->
+ <attribute name="StrictVerifier">true</attribute>
+
+ <depends optional-attribute-name="TransactionManagerServiceName">jboss:service=TransactionManager</depends>
+ <depends optional-attribute-name="WebServiceName">jboss:service=WebService</depends>
+ </mbean>
+
+ <!-- EAR deployer, remove if you are not using Web layers -->
+ <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer">
+ </mbean>
+
+ <mbean code="org.jboss.varia.deployment.BeanShellSubDeployer"
+ name="jboss.scripts:service=BSHDeployer">
+ </mbean>
+
+ <!-- ==================================================================== -->
+ <!-- Monitoring and Management -->
+ <!-- ==================================================================== -->
+
+ <!-- Uncomment to enable JMX monitoring of the bean cache
+ <mbean code="org.jboss.monitor.BeanCacheMonitor"
+ name="jboss.monitor:name=BeanCacheMonitor"/>
+ -->
+
+ <!-- Uncomment to enable JMX monitoring of the entity bean locking
+ <mbean code="org.jboss.monitor.EntityLockMonitor"
+ name="jboss.monitor:name=EntityLockMonitor"/>
+ -->
+
+ <!-- ==================================================================== -->
+ <!-- Deployment Scanning -->
+ <!-- ==================================================================== -->
+
+ <!-- An mbean for hot deployment/undeployment of archives.
+ -->
+ <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
+ name="jboss.deployment:type=DeploymentScanner,flavor=URL">
+
+ <!-- Uncomment (and comment/remove version below) to enable usage of the
+ DeploymentCache
+ <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache</depends>
+ -->
+ <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
+
+ <!-- The URLComparator can be used to specify a deployment ordering
+ for deployments found in a scanned directory. The class specified
+ must be an implementation of java.util.Comparator, it must be able
+ to compare two URL objects, and it must have a no-arg constructor.
+ Two deployment comparators are shipped with JBoss:
+ - org.jboss.deployment.DeploymentSorter
+ Sorts by file extension, as follows:
+ "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip",
+ "*"
+ - org.jboss.deployment.scanner.PrefixDeploymentSorter
+ If the name portion of the url begins with 1 or more digits, those
+ digits are converted to an int (ignoring leading zeroes), and
+ files are deployed in that order. Files that do not start with
+ any digits will be deployed first, and they will be sorted by
+ extension as above with DeploymentSorter.
+ -->
+ <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
+ <!--
+ <attribute name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>
+ -->
+
+ <!-- The Filter specifies a java.io.FileFilter for scanned
+ directories. Any file not accepted by this filter will not be
+ deployed. The org.jboss.deployment.scanner.DeploymentFilter
+ rejects the following patterns:
+ "#*", "%*", ",*", ".*", "_$*", "*#", "*$", "*%", "*.BAK",
+ "*.old", "*.orig", "*.rej", "*.bak", "*,v", "*~", ".make.state",
+ ".nse_depinfo", "CVS", "CVS.admin", "RCS", "RCSLOG", "SCCS",
+ "TAGS", "core", "tags"
+ -->
+ <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>
+
+ <attribute name="ScanPeriod">5000</attribute>
+
+ <!-- URLs are comma separated and resolve relative to the server home URL
+ unless the given path is absolute. If the URL ends in "/" it is
+ considered a collection and scanned, otherwise it is simply deployed;
+ this follows RFC2518 convention and allows discrimination between
+ collections and directories that are simply unpacked archives.
+
+ URLs may be local (file:) or remote (http:). Scanning is supported
+ for remote URLs but unpacked deployment units are not.
+
+ Example URLs:
+ deploy/
+ scans ${jboss.server.url}/deploy/, which is local or remote
+ depending on the URL used to boot the server
+ ${jboss.server.home}/deploy/
+ scans ${jboss.server.home)/deploy, which is always local
+ file:/var/opt/myapp.ear
+ deploy myapp.ear from a local location
+ file:/var/opt/apps/
+ scans the specified directory
+ http://www.test.com/netboot/myapp.ear
+ deploys myapp.ear from a remote location
+ http://www.test.com/netboot/apps/
+ scans the specified WebDAV location
+ -->
+ <attribute name="URLs">
+ deploy/
+ </attribute>
+
+ <!-- Indicates if the scanner should recursively scan directories that
+ contain no "." in their names. This can be used to group applications
+ and services that must be deployed and that have the same
+ logical function in the same directory i.e.
+ deploy/JMX/amples]$
+ deploy/JMS/
+ ...
+ -->
+
+ <attribute name="RecursiveSearch">True</attribute>
+
+ </mbean>
+
+</server>
+
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/server.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/server.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/naming/server.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,167 @@
+<Server>
+
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener" />
+
+ <!-- Use a custom version of StandardService that allows the
+ connectors to be started independent of the normal lifecycle
+ start to allow web apps to be deployed before starting the
+ connectors.
+ -->
+ <Service name="jboss.web">
+
+ <!-- A "Connector" represents an endpoint by which requests are received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL HTTP/1.1 Connector on port 8080
+ -->
+ <Connector port="8080" address="${jboss.bind.address}"
+ maxThreads="250" maxHttpHeaderSize="8192"
+ emptySessionPath="true" protocol="HTTP/1.1"
+ enableLookups="false" redirectPort="8443" acceptCount="100"
+ connectionTimeout="20000" disableUploadTimeout="true" />
+
+ <!-- Define a SSL HTTP/1.1 Connector on port 8443
+ This connector uses the JSSE configuration, when using APR, the
+ connector should be using the OpenSSL style configuration
+ described in the APR documentation -->
+ <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" address="${jboss.bind.address}"
+ maxThreads="100" minSpareThreads="5" maxSpareThreads="15"
+ scheme="https" secure="true" clientAuth="false"
+ keystoreFile="${jboss.server.home.dir}/conf/example.keystore"
+ keystorePass="rmi+ssl" sslProtocol = "TLS" />
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
+ emptySessionPath="true" enableLookups="false" redirectPort="8443" />
+
+ <Engine name="jboss.web" defaultHost="localhost">
+
+ <!-- The JAAS based authentication and authorization realm implementation
+ that is compatible with the jboss 3.2.x realm implementation.
+ - certificatePrincipal : the class name of the
+ org.jboss.security.auth.certs.CertificatePrincipal impl
+ used for mapping X509[] cert chains to a Princpal.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ -->
+ <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ <!-- A subclass of JBossSecurityMgrRealm that uses the authentication
+ behavior of JBossSecurityMgrRealm, but overrides the authorization
+ checks to use JACC permissions with the current java.security.Policy
+ to determine authorized access.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ <Realm className="org.jboss.web.tomcat.security.JaccAuthorizationRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ -->
+
+ <Host name="localhost"
+ autoDeploy="false" deployOnStartup="false" deployXML="false"
+ configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
+ >
+
+ <!-- Uncomment to enable request dumper. This Valve "logs interesting
+ contents from the specified Request (before processing) and the
+ corresponding Response (after processing). It is especially useful
+ in debugging problems related to headers and cookies."
+ -->
+ <!--
+ <Valve className="org.apache.catalina.valves.RequestDumperValve" />
+ -->
+
+ <!-- Access logger -->
+ <!--
+ <Valve className="org.apache.catalina.valves.AccessLogValve"
+ prefix="localhost_access_log." suffix=".log"
+ pattern="common" directory="${jboss.server.home.dir}/log"
+ resolveHosts="false" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host. Does not provide SSO across a cluster.
+
+ If this valve is used, do not use the JBoss ClusteredSingleSignOn
+ valve shown below.
+
+ A new configuration attribute is available beginning with
+ release 4.0.4:
+
+ cookieDomain configures the domain to which the SSO cookie
+ will be scoped (i.e. the set of hosts to
+ which the cookie will be presented). By default
+ the cookie is scoped to "/", meaning the host
+ that presented it. Set cookieDomain to a
+ wider domain (e.g. "xyz.com") to allow an SSO
+ to span more than one hostname.
+ -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host AND to all other hosts in the cluster.
+
+ If this valve is used, do not use the standard Tomcat SingleSignOn
+ valve shown above.
+
+ Valve uses a JBossCache instance to support SSO credential
+ caching and replication across the cluster. The JBossCache
+ instance must be configured separately. By default, the valve
+ shares a JBossCache with the service that supports HttpSession
+ replication. See the "jboss-web-cluster-service.xml" file in the
+ server/all/deploy directory for cache configuration details.
+
+ Besides the attributes supported by the standard Tomcat
+ SingleSignOn valve (see the Tomcat docs), this version also
+ supports the following attributes:
+
+ cookieDomain see above
+
+ treeCacheName JMX ObjectName of the JBossCache MBean used to
+ support credential caching and replication across
+ the cluster. If not set, the default value is
+ "jboss.cache:service=TomcatClusteringCache", the
+ standard ObjectName of the JBossCache MBean used
+ to support session replication.
+ -->
+ <!--
+ <Valve className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn" />
+ -->
+
+ <!-- Check for unclosed connections and transaction terminated checks
+ in servlets/jsps.
+
+ Important: The dependency on the CachedConnectionManager
+ in META-INF/jboss-service.xml must be uncommented, too
+ -->
+ <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
+ cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
+ transactionManagerObjectName="jboss:service=TransactionManager" />
+
+ </Host>
+
+ </Engine>
+
+ </Service>
+
+</Server>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestCase.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestCase.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestCase.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,226 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+
+import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+
+/**
+ * An ejb test case is an extension to test case where the test is executed
+ * in the ejb server's virtual machine.
+ *
+ * Two new methods setUpEJB and tearDownEJB have been added. These methods
+ * work just like setUp and tearDown except they run in a sepperate transaction.
+ * The execution order is as follows:
+ * <pre>
+ * 1. setUpEJB (TX 1)
+ * 2. run (TX 2)
+ * 2.1. runBare
+ * 2.1.1 setUp
+ * 2.1.2 <your test method>
+ * 2.1.3 tearDown
+ * 3. ejbTearDown (TX 2)
+ * </pre>
+ *
+ * For an ejb test case to run successfully, the following must be setup:
+ * <pre>
+ * 1. The ejb test case class must be availabe to the client vm.
+ * 2. The ejb test case class must be availabe to the EJBTestRunner bean
+ * on the server.
+ * 3. The EJBTestRunnerHome must be bound to "ejb/EJBTestRunner" in the
+ * jndi context obtained from new InitialContext();
+ * 4. The EJBTestRunner bean must be configured as specified in the
+ * EJBTestRunner javadoc.
+ * </pre>
+ *
+ * @see EJBTestRunner
+ * @see junit.framework.TestCase
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class EJBTestCase extends TestCase
+{
+ private boolean serverSide = false;
+ protected Properties props;
+
+ /**
+ * Constructs a test case that will run the method with the specified name.
+ * @param methodName the name of the method that will executed when this
+ * test is run
+ */
+ public EJBTestCase(String methodName)
+ {
+ super(methodName);
+ }
+
+ /**
+ * Sets the flag that is used to determine if the class
+ * is running on the server side.
+ * @param serverSide boolean flag that this class uses to determine
+ * if it's running on the server side.
+ */
+ public void setServerSide(boolean serverSide)
+ {
+ this.serverSide = serverSide;
+ }
+
+ /**
+ * Is this class running on the server side?
+ * @return true if this class is running on the server side
+ */
+ public boolean isServerSide()
+ {
+ return serverSide;
+ }
+
+ /** Allow EJBTestCase subclasses to override the EJBRunnerHome JNDI name
+ * @return The JNDI name of the EJBRunnerHome home interface binding. The
+ * default is "ejb/EJBTestRunner"
+ */
+ public String getEJBRunnerJndiName()
+ {
+ return "ejb/EJBTestRunner";
+ }
+
+ /**
+ * @return the properties associated with the test case
+ */
+ public Properties getProps()
+ {
+ return props;
+ }
+ /**
+ * @param props the properties associated with the test case
+ */
+ public void setProps(Properties props)
+ {
+ this.props = props;
+ }
+
+ public void run(TestResult result)
+ {
+ ClassLoader oldClassLoader = null;
+ try
+ {
+ // If we are on the server side, set the thread context class loader
+ // to the class loader that loaded this class. This fixes problems
+ // with the current implementation of the JUnit gui test runners class
+ // reloading logic. The gui relods the test classes with each run but
+ // does not set the context class loader so calls to Class.forName load
+ // the class in the wrong class loader.
+ if (!isServerSide())
+ {
+ oldClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(
+ getClass().getClassLoader());
+ }
+
+ super.run(result);
+ }
+ finally
+ {
+ // be a good citizen, reset the context loader
+ if (oldClassLoader != null)
+ {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+ }
+
+ public void runBare() throws Throwable
+ {
+ if (!isServerSide())
+ {
+ // We're not on the server side yet, invoke the test on the serverside.
+ EJBTestRunner testRunner = null;
+ try
+ {
+ testRunner = getEJBTestRunner();
+ if( props != null )
+ testRunner.run(getClass().getName(), getName(), props);
+ else
+ testRunner.run(getClass().getName(), getName());
+ }
+ catch (RemoteTestException e)
+ {
+ // if the remote test exception is from an assertion error
+ // rethrow it with a sub class of AssertionFailedError so it is
+ // picked up as a failure and not an error.
+ // The server has to throw sub classes of Error because that is the
+ // allowable scope of application exceptions. So
+ // AssertionFailedError which is an instance of error has to be
+ // wrapped in an exception.
+ Throwable remote = e.getRemoteThrowable();
+ if (remote instanceof AssertionFailedError)
+ {
+ throw new RemoteAssertionFailedError(
+ (AssertionFailedError) remote, e.getRemoteStackTrace());
+ }
+ throw e;
+ }
+ finally
+ {
+ // be a good citizen, drop my ref to the session bean.
+ if (testRunner != null)
+ {
+ testRunner.remove();
+ }
+ }
+ }
+ else
+ {
+ // We're on the server side so, invoke the test the usual way.
+ super.runBare();
+ }
+ }
+
+ /** Sets up the ejb test case. This method is called before
+ * each test is executed and is run in a private transaction.
+ * @param props the properties passed in from the client
+ * @throws Exception if a problem occures
+ */
+ public void setUpEJB(Properties props) throws Exception
+ {
+ this.props = props;
+ }
+
+ /** Tears down the ejb test case. This method is called after
+ * each test is executed and is run in a private transaction.
+ * @param props the properties passed in from the client
+ * @throws Exception if a problem occures
+ */
+ public void tearDownEJB(Properties props) throws Exception
+ {
+ }
+
+ /**
+ * Looks up the ejb test runner home in JNDI (at "ejb/EJBTestRunner")
+ * and creates a new runner.
+ * @throws Exception if any problem happens
+ */
+ private EJBTestRunner getEJBTestRunner() throws Exception
+ {
+ InitialContext jndiContext = new InitialContext();
+
+ // Get a reference from this to the Bean's Home interface
+ String name = getEJBRunnerJndiName();
+ Object ref = jndiContext.lookup(name);
+ EJBTestRunnerHome runnerHome = (EJBTestRunnerHome)
+ PortableRemoteObject.narrow(ref, EJBTestRunnerHome.class);
+
+ // create the test runner
+ return runnerHome.create();
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunner.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunner.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunner.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,76 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+import java.rmi.RemoteException;
+import java.util.Properties;
+import javax.ejb.EJBObject;
+
+/**
+ * The remote interface of the server side test runner. The EJBTestClient calls
+ * run with the names of the test class and test method to execute. Then run
+ * calls setUpEJB, runTestCase, and tearDownEJB in sepperate transactions. In
+ * order for the the tests to run as expected by the client the EJBTestRunner
+ * bean must be setup exactly as follows in the ejb-jar.xml file:
+ * <pre>
+ * <?xml version="1.0"?>
+ * <!DOCTYPE ejb-jar PUBLIC
+ * "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ * "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
+ * <ejb-jar>
+ * <enterprise-beans>
+ * <session>
+ * <description>JUnit Session Bean Test Runner</description>
+ * <ejb-name>EJBTestRunnerEJB</ejb-name>
+ * <home>net.sourceforge.junitejb.EJBTestRunnerHome</home>
+ * <remote>net.sourceforge.junitejb.EJBTestRunner</remote>
+ * <ejb-class>net.sourceforge.junitejb.EJBTestRunnerBean</ejb-class>
+ * <session-type>Stateless</session-type>
+ * <transaction-type>Bean</transaction-type>
+ * </session>
+ * </enterprise-beans>
+ * </ejb-jar>
+ * </pre>
+ *
+ * Additionally, the home interface must be bount to the jndi name:
+ * "ejb/EJBTestRunner"
+ *
+ * It is recomended that the test classes and the classes of JUnitEJB be
+ * packaged into a single jar.
+ *
+ * @see EJBTestCase
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface EJBTestRunner extends EJBObject
+{
+ /** Runs the specified test method on the specified class by calling
+ * run(className, methodName, props) with props built from the java:comp/env
+ * bindings.
+ *
+ * @param className the name of the test class
+ * @param methodName the name of the test method
+ * @throws RemoteTestException If any throwable is thrown during execution
+ * of the method, it is wrapped with a RemoteTestException and rethrown.
+ */
+ public void run(String className, String methodName)
+ throws RemoteTestException, RemoteException;
+
+ /**
+ * Runs the specified test method on the specified class.
+ * @param className the name of the test class
+ * @param methodName the name of the test method
+ * @param props any properties passed in from the client for use by the
+ * server side tests
+ * @throws RemoteTestException If any throwable is thrown during execution
+ * of the method, it is wrapped with a RemoteTestException and rethrown.
+ */
+ public void run(String className, String methodName, Properties props)
+ throws RemoteTestException, RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,311 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+import java.lang.reflect.Constructor;
+import java.util.Properties;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Binding;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+
+/**
+ * Implementation of the ejb test runner.
+ *
+ * @see EJBTestRunner
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class EJBTestRunnerBean implements SessionBean
+{
+ transient private SessionContext ctx;
+ private String runnerJndiName;
+
+ /** Run the specified test method on the given class name using a Properties
+ * map built from all java:comp/env entries.
+ *
+ * @param className the name of the test class
+ * @param methodName the name of the test method
+ * @throws RemoteTestException If any throwable is thrown during
+ * execution of the method, it is wrapped with a RemoteTestException and
+ * rethrown.
+ */
+ public void run(String className, String methodName)
+ throws RemoteTestException
+ {
+ Properties props = new Properties();
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ NamingEnumeration bindings = ctx.listBindings("java:comp/env");
+ while( bindings.hasMore() )
+ {
+ Binding binding = (Binding) bindings.next();
+ String name = binding.getName();
+ String value = binding.getObject().toString();
+ props.setProperty(name, value);
+ }
+ }
+ catch(NamingException e)
+ {
+ throw new RemoteTestException(e);
+ }
+ run(className, methodName, props);
+ }
+
+ /** Run the specified test method on the given class name
+ *
+ * @param className the name of the test class
+ * @param methodName the name of the test method
+ * @param props
+ * @throws RemoteTestException If any throwable is thrown during
+ * execution of the method, it is wrapped with a RemoteTestException and
+ * rethrown.
+ */
+ public void run(String className, String methodName, Properties props)
+ throws RemoteTestException
+ {
+ EJBTestCase testCase = getTestInstance(className, methodName);
+
+ setUpEJB(testCase, props);
+
+ RemoteTestException exception = null;
+ try
+ {
+ runTestCase(testCase);
+ }
+ catch (RemoteTestException e)
+ {
+ exception = e;
+ }
+ finally
+ {
+ try
+ {
+ tearDownEJB(testCase, props);
+ }
+ catch (RemoteTestException e)
+ {
+ // favor the run exception if one was thrown
+ if (exception != null)
+ {
+ exception = e;
+ }
+ }
+ if (exception != null)
+ {
+ throw exception;
+ }
+ }
+ }
+
+ /**
+ * Runs the setUpEJB method on the specified test case
+ * @param testCase the actual test case that will be run
+ * @throws RemoteTestException If any throwable is thrown during execution
+ * of the method, it is wrapped with a RemoteTestException and rethrown.
+ */
+ private void setUpEJB(EJBTestCase testCase, Properties props)
+ throws RemoteTestException
+ {
+ try
+ {
+ ctx.getUserTransaction().begin();
+ try
+ {
+ testCase.setUpEJB(props);
+ }
+ catch (Throwable e)
+ {
+ throw new RemoteTestException(e);
+ }
+ if (ctx.getUserTransaction().getStatus() == Status.STATUS_ACTIVE)
+ {
+ ctx.getUserTransaction().commit();
+ }
+ }
+ catch (Throwable e)
+ {
+ try
+ {
+ ctx.getUserTransaction().rollback();
+ }
+ catch (SystemException unused)
+ {
+ // eat the exception we are exceptioning out anyway
+ }
+ if (e instanceof RemoteTestException)
+ {
+ throw (RemoteTestException) e;
+ }
+ throw new RemoteTestException(e);
+ }
+ }
+
+ /**
+ * Runs the test method on the specified test case
+ * @param testCase the actual test case that will be run
+ * @throws RemoteTestException If any throwable is thrown during execution
+ * of the method, it is wrapped with a RemoteTestException and rethrown.
+ */
+ private void runTestCase(EJBTestCase testCase) throws RemoteTestException
+ {
+ try
+ {
+ ctx.getUserTransaction().begin();
+ try
+ {
+ testCase.runBare();
+ }
+ catch (Throwable e)
+ {
+ throw new RemoteTestException(e);
+ }
+ if (ctx.getUserTransaction().getStatus() == Status.STATUS_ACTIVE)
+ {
+ ctx.getUserTransaction().commit();
+ }
+ }
+ catch (Throwable e)
+ {
+ try
+ {
+ ctx.getUserTransaction().rollback();
+ }
+ catch (SystemException unused)
+ {
+ // eat the exception we are exceptioning out anyway
+ }
+ if (e instanceof RemoteTestException)
+ {
+ throw (RemoteTestException) e;
+ }
+ throw new RemoteTestException(e);
+ }
+ }
+
+ /**
+ * Runs the tearDownEJB method on the specified test case
+ * @param testCase the actual test case that will be run
+ * @throws RemoteTestException If any throwable is thrown during execution
+ * of the method, it is wrapped with a RemoteTestException and rethrown.
+ */
+ private void tearDownEJB(EJBTestCase testCase, Properties props)
+ throws RemoteTestException
+ {
+
+ try
+ {
+ ctx.getUserTransaction().begin();
+ try
+ {
+ testCase.tearDownEJB(props);
+ }
+ catch (Throwable e)
+ {
+ throw new RemoteTestException(e);
+ }
+ if (ctx.getUserTransaction().getStatus() == Status.STATUS_ACTIVE)
+ {
+ ctx.getUserTransaction().commit();
+ }
+ }
+ catch (Throwable e)
+ {
+ try
+ {
+ ctx.getUserTransaction().rollback();
+ }
+ catch (SystemException unused)
+ {
+ // eat the exception we are exceptioning out anyway
+ }
+ if (e instanceof RemoteTestException)
+ {
+ throw (RemoteTestException) e;
+ }
+ throw new RemoteTestException(e);
+ }
+ }
+
+ /**
+ * Gets a instance of the test class with the specified class name and
+ * initialized to execute the specified method.
+ *
+ * @param className the name of the test class
+ * @param methodName the name of the test method
+ * @return a new instance of the test class with the specified class name and
+ * initialized to execute the specified method.
+ */
+ private EJBTestCase getTestInstance(String className, String methodName)
+ {
+ Class testClass = null;
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ testClass = loader.loadClass(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new EJBException("Test class not found : " + className);
+ }
+
+ Constructor constructor = null;
+ try
+ {
+ constructor = testClass.getConstructor(new Class[]{String.class});
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new EJBException("Test class does not have a constructor " +
+ "which has a single String argument.");
+ }
+
+ try
+ {
+ EJBTestCase testCase =
+ (EJBTestCase) constructor.newInstance(new Object[]{methodName});
+ testCase.setServerSide(true);
+ return testCase;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new EJBException("Cannot instantiate test class: " +
+ testClass.getName());
+ }
+ }
+
+ public void ejbCreate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void setSessionContext(SessionContext ctx)
+ {
+ this.ctx = ctx;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/EJBTestRunnerHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,26 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * Remote home interface of the ejb test runner.
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EJBTestRunnerHome extends EJBHome
+{
+ /**
+ * Creates an ejb test runner.
+ * @return a new EJBTestRunner
+ */
+ public EJBTestRunner create() throws RemoteException, CreateException;
+}
\ No newline at end of file
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteAssertionFailedError.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteAssertionFailedError.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteAssertionFailedError.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,102 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * RemoteAssertionFailedError is the client-side view of an assertion
+ * failed error on the server.
+ *
+ * All throwables caught on the server are wrapped with a RemoteTestException
+ * and rethrown. On the client side the exception is caught, and if the
+ * server side exception is an instance of AssertionFailedError, it is
+ * wrapped with an instance of this class and rethrown. That makes the
+ * exception an instance of AssertionFailedError so it is reconized as
+ * a failure and not an Error.
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteAssertionFailedError extends AssertionFailedError
+{
+ private AssertionFailedError remoteAssertionFailedError;
+ private String remoteStackTrace;
+
+ /**
+ * Constructs a remote assertion failed error based on the specified
+ * AssertionFailedError and remote stack trace.
+ * @param e the AssertionFailedError that was thrown on the server side
+ * @param remoteStackTrace the stack trace of the assertion failed error
+ * exactly as it appeared on the server side
+ */
+ public RemoteAssertionFailedError(
+ AssertionFailedError e,
+ String remoteStackTrace)
+ {
+
+ remoteAssertionFailedError = e;
+ this.remoteStackTrace = remoteStackTrace;
+ }
+
+ /**
+ * Gets the message exactly as it appeared on server side.
+ * @return the message exactly as it appeared on server side
+ */
+ public String getMessage()
+ {
+ return remoteAssertionFailedError.getMessage();
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ * @param ps the PrintStream on which the stack trace is printed
+ */
+ public void printStackTrace(java.io.PrintStream ps)
+ {
+ ps.print(remoteStackTrace);
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ */
+ public void printStackTrace()
+ {
+ printStackTrace(System.err);
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ * @param pw the PrintWriter on which the stack trace is printed
+ */
+ public void printStackTrace(java.io.PrintWriter pw)
+ {
+ pw.print(remoteStackTrace);
+ }
+
+ /**
+ * Gets the assertion failed error object from the server side.
+ * Note: the stack trace of this object is not available because
+ * exceptions don't seralize the stack trace. Use
+ * getRemoteStackTrace to get the stack trace as it appeared
+ * on the server.
+ * @retun the assertion failed error object from the server side.
+ */
+ public AssertionFailedError getRemoteAssertionFailedError()
+ {
+ return remoteAssertionFailedError;
+ }
+
+ /**
+ * Gets the stack trace exactly as it appeared on the server side.
+ * @return the stack trace exactly as it appeared on the server side
+ */
+ public String getRemoteStackTrace()
+ {
+ return remoteStackTrace;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteTestException.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteTestException.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/test/util/ejb/RemoteTestException.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,103 @@
+/*
+ * JUnitEJB
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.util.ejb;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * RemoteTestException is the client-side view of a throwable on the server.
+ *
+ * All throwables caught on the server are wrapped with a RemoteTestException
+ * and rethrown. On the client side the exception is caught, and if the
+ * server side exception is an instance of AssertionFailedError, it is
+ * wrapped with a RemoteAssertionFailedError and rethrown. That makes the
+ * exception an instance of AssertionFailedError so it is reconized as
+ * a failure and not an Error.
+ *
+ * @author <a href="mailto:dain at daingroup.com">Dain Sundstrom</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteTestException extends Exception
+{
+ private Throwable remoteThrowable;
+ private String remoteStackTrace;
+
+ /**
+ * Constructs a remote test exception that wrapps the the specified
+ * throwable.
+ * @param e the Throwable that was thrown on the server side
+ */
+ public RemoteTestException(Throwable e)
+ {
+ remoteThrowable = e;
+
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter writer = new PrintWriter(stringWriter);
+ e.printStackTrace(writer);
+ StringBuffer buffer = stringWriter.getBuffer();
+ remoteStackTrace = buffer.toString();
+ }
+
+ /**
+ * Gets the message exactly as it appeared on server side.
+ * @return the message exactly as it appeared on server side
+ */
+ public String getMessage()
+ {
+ return remoteThrowable.getMessage();
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ * @param ps the PrintStream on which the stack trace is printed
+ */
+ public void printStackTrace(java.io.PrintStream ps)
+ {
+ ps.print(remoteStackTrace);
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ */
+ public void printStackTrace()
+ {
+ printStackTrace(System.err);
+ }
+
+ /**
+ * Prints the stack trace exactly as it appeared on the server side.
+ * @param pw the PrintWriter on which the stack trace is printed
+ */
+ public void printStackTrace(java.io.PrintWriter pw)
+ {
+ pw.print(remoteStackTrace);
+ }
+
+ /**
+ * Gets the throwable object from the server side.
+ * Note: the stack trace of this object is not available because
+ * exceptions don't seralize the stack trace. Use
+ * getRemoteStackTrace to get the stack trace as it appeared
+ * on the server.
+ * @return the Throwable object from the server side.
+ */
+ public Throwable getRemoteThrowable()
+ {
+ return remoteThrowable;
+ }
+
+ /**
+ * Gets the stack trace exactly as it appeared on the server side.
+ * @return the stack trace exactly as it appeared on the server side
+ */
+ public String getRemoteStackTrace()
+ {
+ return remoteStackTrace;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/ChapterExRepository.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/ChapterExRepository.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/ChapterExRepository.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,118 @@
+package org.jboss.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.log4j.Hierarchy;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.RepositorySelector;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.log4j.spi.RootCategory;
+import org.apache.log4j.xml.DOMConfigurator;
+
+/** An implementation of the Log4j RepositorySelector that looks for chapter
+ * example local log4j.xml files
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ChapterExRepository implements RepositorySelector
+{
+ private static RepositorySelector theSelector;
+ private static Object guard = new Object();
+ private Hierarchy heirarchy;
+
+ public static synchronized void init(Class mainClass)
+ {
+ if( theSelector == null )
+ {
+ String name = mainClass.getName();
+ Hierarchy heirarchy = new Hierarchy(new RootCategory(Level.DEBUG));
+ // Locate the log4j.xml or log4j.properties config
+ InputStream is = findConfig(name, heirarchy);
+ if( is == null )
+ throw new IllegalStateException("Failed to find any log4j.xml config");
+
+ DOMConfigurator config = new DOMConfigurator();
+ config.doConfigure(is, heirarchy);
+ theSelector = new ChapterExRepository(heirarchy);
+ // Establish the RepositorySelector
+ LogManager.setRepositorySelector(theSelector, guard);
+ }
+ }
+
+ private ChapterExRepository(Hierarchy heirarchy)
+ {
+ this.heirarchy = heirarchy;
+ }
+
+ public LoggerRepository getLoggerRepository()
+ {
+ return heirarchy;
+ }
+
+ private static InputStream findConfig(String name, Hierarchy heirarchy)
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = null;
+
+ // First look for a resource: "name / log4j-suffix(name).xml"
+ String prefix = "";
+ String suffix = name;
+ int dot = name.lastIndexOf('.');
+ if( dot >= 0 )
+ {
+ prefix = name.substring(0, dot);
+ suffix = name.substring(dot+1);
+ }
+ prefix = prefix.replace('.', '/');
+
+ String log4jxml = prefix + "/log4j-" + suffix + ".xml";
+ URL resURL = tcl.getResource(log4jxml);
+ if( resURL != null )
+ {
+ try
+ {
+ is = resURL.openStream();
+ System.out.println("Found resURL: "+resURL);
+ return is;
+ }
+ catch(IOException e)
+ {
+ }
+ }
+
+ // Next look for resource name / + log4j.xml
+ log4jxml = prefix + "/log4j.xml";
+ resURL = tcl.getResource(log4jxml);
+ if( resURL != null )
+ {
+ try
+ {
+ is = resURL.openStream();
+ }
+ catch(IOException e)
+ {
+ }
+ //System.out.println("Found resURL: "+resURL);
+ return is;
+ }
+
+ // Next look for just the log4j.xml res
+ log4jxml = "log4j.xml";
+ resURL = tcl.getResource(log4jxml);
+ if( resURL != null )
+ {
+ try
+ {
+ is = resURL.openStream();
+ //System.out.println("Found resURL: "+resURL);
+ }
+ catch(IOException e)
+ {
+ }
+ }
+ return is;
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/Debug.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/Debug.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/util/Debug.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,91 @@
+package org.jboss.util;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+/** Various debugging utility methods available for use in unit tests
+ * @author Scott.Stark at jboss.org
+ */
+public class Debug
+{
+ /** Format a string buffer containing the Class, Interfaces, CodeSource,
+ and ClassLoader information for the given object clazz.
+
+ @param clazz the Class
+ @param results, the buffer to write the info to
+ */
+ public static void displayClassInfo(Class clazz, StringBuffer results)
+ {
+ displayClassInfo(clazz, results, true);
+ }
+ public static void displayClassInfo(Class clazz, StringBuffer results,
+ boolean showParentClassLoaders)
+ {
+
+ ClassLoader cl = clazz.getClassLoader();
+ results.append("\n"+clazz.getName()+"("+Integer.toHexString(clazz.hashCode())+").ClassLoader="+cl);
+ ClassLoader parent = cl;
+ while( parent != null )
+ {
+ results.append("\n.."+parent);
+ URL[] urls = getClassLoaderURLs(parent);
+ int length = urls != null ? urls.length : 0;
+ for(int u = 0; u < length; u ++)
+ {
+ results.append("\n...."+urls[u]);
+ }
+ if( showParentClassLoaders == false )
+ break;
+ if( parent != null )
+ parent = parent.getParent();
+ }
+ CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
+ if( clazzCS != null )
+ results.append("\n++++CodeSource: "+clazzCS);
+ else
+ results.append("\n++++Null CodeSource");
+
+ results.append("\nImplemented Interfaces:");
+ Class[] ifaces = clazz.getInterfaces();
+ for(int i = 0; i < ifaces.length; i ++)
+ {
+ Class iface = ifaces[i];
+ results.append("\n++"+iface+"("+Integer.toHexString(iface.hashCode())+")");
+ ClassLoader loader = ifaces[i].getClassLoader();
+ results.append("\n++++ClassLoader: "+loader);
+ ProtectionDomain pd = ifaces[i].getProtectionDomain();
+ CodeSource cs = pd.getCodeSource();
+ if( cs != null )
+ results.append("\n++++CodeSource: "+cs);
+ else
+ results.append("\n++++Null CodeSource");
+ }
+ }
+
+ /** Use reflection to access a URL[] getURLs or ULR[] getAllURLs method so
+ that non-URLClassLoader class loaders, or class loaders that override
+ getURLs to return null or empty, can provide the true classpath info.
+ */
+ public static URL[] getClassLoaderURLs(ClassLoader cl)
+ {
+ URL[] urls = {};
+ try
+ {
+ Class returnType = urls.getClass();
+ Class[] parameterTypes = {};
+ Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
+ if( returnType.isAssignableFrom(getURLs.getReturnType()) )
+ {
+ Object[] args = {};
+ urls = (URL[]) getURLs.invoke(cl, args);
+ }
+ }
+ catch(Exception ignore)
+ {
+ }
+ return urls;
+ }
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/application.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/application.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/application.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application>
+ <display-name>Chapter 12 Example EAR</display-name>
+
+ <module>
+ <ejb>hello-ejb.jar</ejb>
+ </module>
+
+ <module>
+ <java>hello-ejb.wsr</java>
+ </module>
+</application>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/ExampleClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/ExampleClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/ExampleClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,20 @@
+package org.jboss.ws.client;
+
+import org.jboss.ws.example.Example;
+import org.jboss.ws.example.ExampleHome;
+
+import javax.naming.*;
+
+public class ExampleClient
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ ExampleHome home = (ExampleHome) ctx.lookup("Example");
+ Example example = (Example) home.create();
+
+ System.out.println("output:" + example.doWork());
+ }
+}
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClient.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClient.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClient.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,35 @@
+package org.jboss.ws.client;
+
+import org.jboss.ws.hello.Hello;
+
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceFactory;
+
+import javax.xml.namespace.QName;
+
+import java.net.URL;
+
+public class HelloClient
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ String urlstr = args[0];
+ String argument = args[1];
+
+ System.out.println("Contacting webservice at " + urlstr);
+
+ URL url = new URL(urlstr);
+
+ QName qname = new QName("http://hello.ws.jboss.org/",
+ "HelloService");
+
+ ServiceFactory factory = ServiceFactory.newInstance();
+ Service service = factory.createService(url, qname);
+
+ Hello hello = (Hello) service.getPort(Hello.class);
+
+ System.out.println("hello.hello(" + argument + ")");
+ System.out.println("output:" + hello.hello(argument));
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClientDII.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClientDII.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/client/HelloClientDII.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,37 @@
+package org.jboss.ws.client;
+
+import org.jboss.ws.hello.Hello;
+
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceFactory;
+import javax.xml.rpc.Call;
+
+import javax.xml.namespace.QName;
+
+import java.net.URL;
+
+public class HelloClientDII
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ String urlstr = args[0];
+ String argument = args[1];
+
+ System.out.println("Contacting webservice at " + urlstr);
+
+ URL url = new URL(urlstr);
+
+ String ns = "http://hello.ws.jboss.org/";
+ QName qname = new QName(ns, "HelloService");
+ QName port = new QName(ns, "HelloPort");
+ QName operation = new QName(ns, "hello");
+
+ ServiceFactory factory = ServiceFactory.newInstance();
+ Service service = factory.createService(url, qname);
+ Call call = service.createCall(port, operation);
+
+ System.out.println("hello.hello(" + argument + ")");
+ System.out.println("output:" + call.invoke(new Object[] {argument}));
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
+ <display-name>chapter 12 EJB JAR</display-name>
+ <enterprise-beans>
+ <session>
+ <ejb-name>HelloBean</ejb-name>
+ <service-endpoint>org.jboss.ws.hello.Hello</service-endpoint>
+ <ejb-class>org.jboss.ws.hello.HelloBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+ <assembly-descriptor>
+ <method-permission>
+ <unchecked/>
+ <method>
+ <ejb-name>HelloBean</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ </method-permission>
+ <container-transaction>
+ <method>
+ <ejb-name>HelloBean</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/mapping.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/mapping.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/mapping.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<java-wsdl-mapping version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
+ <package-mapping>
+ <package-type>org.jboss.ws.hello</package-type>
+ <namespaceURI>http://hello.ws.jboss.org/types</namespaceURI>
+ </package-mapping>
+ <package-mapping>
+ <package-type>org.jboss.ws.hello</package-type>
+ <namespaceURI>http://hello.ws.jboss.org/</namespaceURI>
+ </package-mapping>
+ <service-interface-mapping>
+ <service-interface>org.jboss.ws.hello.HelloService</service-interface>
+ <wsdl-service-name xmlns:serviceNS="http://hello.ws.jboss.org/">serviceNS:HelloService</wsdl-service-name>
+ <port-mapping>
+ <port-name>HelloPort</port-name>
+ <java-port-name>HelloPort</java-port-name>
+ </port-mapping>
+ </service-interface-mapping>
+ <service-endpoint-interface-mapping>
+ <service-endpoint-interface>org.jboss.ws.hello.Hello</service-endpoint-interface>
+ <wsdl-port-type xmlns:portTypeNS="http://hello.ws.jboss.org/">portTypeNS:Hello</wsdl-port-type>
+ <wsdl-binding xmlns:bindingNS="http://hello.ws.jboss.org/">bindingNS:HelloBinding</wsdl-binding>
+ <service-endpoint-method-mapping>
+ <java-method-name>hello</java-method-name>
+ <wsdl-operation>hello</wsdl-operation>
+ <method-param-parts-mapping>
+ <param-position>0</param-position>
+ <param-type>java.lang.String</param-type>
+ <wsdl-message-mapping>
+ <wsdl-message xmlns:wsdlMsgNS="http://hello.ws.jboss.org/">wsdlMsgNS:Hello_hello</wsdl-message>
+ <wsdl-message-part-name>String_1</wsdl-message-part-name>
+ <parameter-mode>IN</parameter-mode>
+ </wsdl-message-mapping>
+ </method-param-parts-mapping>
+ <wsdl-return-value-mapping>
+ <method-return-value>java.lang.String</method-return-value>
+ <wsdl-message xmlns:wsdlMsgNS="http://hello.ws.jboss.org/">wsdlMsgNS:Hello_helloResponse</wsdl-message>
+ <wsdl-message-part-name>result</wsdl-message-part-name>
+ </wsdl-return-value-mapping>
+ </service-endpoint-method-mapping>
+ </service-endpoint-interface-mapping>
+</java-wsdl-mapping>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/webservices.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/webservices.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/ejbmeta/webservices.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,20 @@
+ <webservices xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
+ version="1.1">
+
+ <webservice-description>
+ <webservice-description-name>HelloService</webservice-description-name>
+ <wsdl-file>META-INF/wsdl/HelloService.wsdl</wsdl-file>
+ <jaxrpc-mapping-file>META-INF/mapping.xml</jaxrpc-mapping-file>
+
+ <port-component>
+ <port-component-name>Hello</port-component-name>
+ <wsdl-port>HelloPort</wsdl-port>
+ <service-endpoint-interface>org.jboss.ws.hello.Hello</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>HelloBean</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+</webservices>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/Example.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/Example.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/Example.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,12 @@
+package org.jboss.ws.example;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+
+
+public interface Example
+ extends EJBObject
+{
+ public String doWork()
+ throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,47 @@
+package org.jboss.ws.example;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import java.rmi.RemoteException;
+import org.jboss.ws.hello.Hello;
+
+public class ExampleBean
+ implements SessionBean
+{
+ public String doWork()
+ {
+ try {
+ Context ctx = new InitialContext();
+
+ Service service = (Service) ctx.lookup("java:comp/env/services/hello");
+ Hello hello = (Hello) service.getPort(Hello.class);
+
+ return hello.hello("example bean");
+ } catch (NamingException e) {
+ throw new EJBException(e);
+
+ } catch (ServiceException e) {
+ throw new EJBException(e);
+
+ } catch (RemoteException e) {
+ throw new EJBException(e);
+ }
+ }
+
+ public void ejbCreate() {};
+ public void ejbRemove() {};
+
+ public void ejbActivate() {}
+ public void ejbPassivate() {}
+
+ public void setSessionContext(SessionContext ctx) {}
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleHome.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleHome.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ExampleHome.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,13 @@
+package org.jboss.ws.example;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+
+public interface ExampleHome
+ extends EJBHome
+{
+ public Example create()
+ throws CreateException,
+ RemoteException;
+
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ejb-jar.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ejb-jar.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/ejb-jar.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ xmlns:hello="http://hello.ws.jboss.org/"
+ version="2.1">
+
+ <display-name>example bean</display-name>
+
+ <enterprise-beans>
+ <session>
+ <ejb-name>Example</ejb-name>
+
+ <home>org.jboss.ws.example.ExampleHome</home>
+ <remote>org.jboss.ws.example.Example</remote>
+ <ejb-class>org.jboss.ws.example.ExampleBean</ejb-class>
+
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+
+ <service-ref>
+ <service-ref-name>services/hello</service-ref-name>
+ <service-interface>javax.xml.rpc.Service</service-interface>
+ <wsdl-file>META-INF/wsdl/hello.wsdl</wsdl-file>
+ <jaxrpc-mapping-file>META-INF/mapping.xml</jaxrpc-mapping-file>
+ <service-qname>hello:HelloService</service-qname>
+
+ </service-ref>
+
+ </session>
+ </enterprise-beans>
+</ejb-jar>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/jboss.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/jboss.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/jboss.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,14 @@
+<!DOCTYPE jboss PUBLIC
+ "-//JBoss//DTD JBOSS 4.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>Example</ejb-name>
+ <service-ref>
+ <service-ref-name>services/hello</service-ref-name>
+ <wsdl-override>http://localhost:8080/hello-servlet/Hello?wsdl</wsdl-override>
+ </service-ref>
+ </session>
+ </enterprise-beans>
+</jboss>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/mapping.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/mapping.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/example/mapping.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<java-wsdl-mapping version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
+ <package-mapping>
+ <package-type>org.jboss.ws.hello</package-type>
+ <namespaceURI>http://hello.ws.jboss.org/types</namespaceURI>
+ </package-mapping>
+ <package-mapping>
+ <package-type>org.jboss.ws.hello</package-type>
+ <namespaceURI>http://hello.ws.jboss.org/</namespaceURI>
+ </package-mapping>
+ <service-interface-mapping>
+ <service-interface>org.jboss.ws.hello.HelloService</service-interface>
+ <wsdl-service-name xmlns:serviceNS="http://hello.ws.jboss.org/">serviceNS:HelloService</wsdl-service-name>
+ <port-mapping>
+ <port-name>HelloPort</port-name>
+ <java-port-name>HelloPort</java-port-name>
+ </port-mapping>
+ </service-interface-mapping>
+ <service-endpoint-interface-mapping>
+ <service-endpoint-interface>org.jboss.ws.hello.Hello</service-endpoint-interface>
+ <wsdl-port-type xmlns:portTypeNS="http://hello.ws.jboss.org/">portTypeNS:Hello</wsdl-port-type>
+ <wsdl-binding xmlns:bindingNS="http://hello.ws.jboss.org/">bindingNS:HelloBinding</wsdl-binding>
+ <service-endpoint-method-mapping>
+ <java-method-name>hello</java-method-name>
+ <wsdl-operation>hello</wsdl-operation>
+ <method-param-parts-mapping>
+ <param-position>0</param-position>
+ <param-type>java.lang.String</param-type>
+ <wsdl-message-mapping>
+ <wsdl-message xmlns:wsdlMsgNS="http://hello.ws.jboss.org/">wsdlMsgNS:Hello_hello</wsdl-message>
+ <wsdl-message-part-name>String_1</wsdl-message-part-name>
+ <parameter-mode>IN</parameter-mode>
+ </wsdl-message-mapping>
+ </method-param-parts-mapping>
+ <wsdl-return-value-mapping>
+ <method-return-value>java.lang.String</method-return-value>
+ <wsdl-message xmlns:wsdlMsgNS="http://hello.ws.jboss.org/">wsdlMsgNS:Hello_helloResponse</wsdl-message>
+ <wsdl-message-part-name>result</wsdl-message-part-name>
+ </wsdl-return-value-mapping>
+ </service-endpoint-method-mapping>
+ </service-endpoint-interface-mapping>
+</java-wsdl-mapping>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/Hello.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/Hello.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/Hello.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+package org.jboss.ws.hello;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface Hello
+ extends Remote
+{
+ public String hello(String name)
+ throws RemoteException;
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloBean.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloBean.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloBean.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,22 @@
+package org.jboss.ws.hello;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+public class HelloBean
+ implements SessionBean
+{
+ public String hello(String name)
+ {
+ return "Hello " + name + "!";
+ }
+
+ public void ejbCreate() {};
+ public void ejbRemove() {};
+
+ public void ejbActivate() {}
+ public void ejbPassivate() {}
+
+ public void setSessionContext(SessionContext ctx) {}
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloPojo.java
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloPojo.java (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/HelloPojo.java 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,9 @@
+package org.jboss.ws.hello;
+
+public class HelloPojo
+{
+ public String hello(String name)
+ {
+ return "Hello " + name + "!";
+ }
+}
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/config.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/config.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/hello/config.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
+ <service name="HelloService"
+ targetNamespace="http://hello.ws.jboss.org/"
+ typeNamespace="http://hello.ws.jboss.org/types"
+ packageName="org.jboss.ws.hello">
+ <interface name="org.jboss.ws.hello.Hello"/>
+ </service>
+</configuration>
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/servletmeta/web.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/servletmeta/web.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/servletmeta/web.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>HelloWorldWS</servlet-name>
+ <servlet-class>org.jboss.ws.hello.HelloPojo</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloWorldWS</servlet-name>
+ <url-pattern>/Hello</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-ejb-config.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-ejb-config.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-ejb-config.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,11 @@
+<configuration xmlns="http://www.jboss.org/jbossws-tools">
+ <java-wsdl>
+ <service name="HelloService"
+ style="rpc"
+ endpoint="org.jboss.ws.hello.Hello"/>
+ <namespaces target-namespace="http://hello.ws.jboss.org/"
+ type-namespace="http://hello.ws.jboss.org/types"/>
+ <mapping file="jaxrpc-mapping.xml"/>
+ <webservices ejb-link="HelloBean"/>
+ </java-wsdl>
+</configuration>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-servlet-config.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-servlet-config.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/main/org/jboss/ws/wstools-servlet-config.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,9 @@
+<configuration xmlns="http://www.jboss.org/jbossws-tools">
+ <java-wsdl>
+ <service name="HelloService" style="rpc" endpoint="org.jboss.ws.hello.Hello"/>
+ <namespaces target-namespace="http://hello.ws.jboss.org/"
+ type-namespace="http://hello.ws.jboss.org/types"/>
+ <mapping file="jaxrpc-mapping.xml"/>
+ <webservices servlet-link="HelloWorldWS"/>
+ </java-wsdl>
+</configuration>
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/app.policy
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/app.policy (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/app.policy 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,4 @@
+grant {
+ permission java.security.AllPermission;
+};
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/auth.conf
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/auth.conf (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/auth.conf 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,46 @@
+
+srp {
+ org.jboss.security.srp.jaas.SRPLoginModule required
+ srpServerJndiName="srp-test/SRPServerInterface"
+ ;
+
+ org.jboss.security.ClientLoginModule required
+ password-stacking="useFirstPass"
+ ;
+};
+
+// Clustered SRP using HTTP as the transport
+srpHA {
+ org.jboss.security.srp.jaas.SRPLoginModule required
+ srpServerJndiName="srp-test/SRPServerInterfaceHA"
+ ;
+
+ org.jboss.security.ClientLoginModule required
+ password-stacking="useFirstPass"
+ ;
+};
+
+/* Clustered SRP using HTTP as the transport with secured JNDI and
+a srp-test read-only context
+*/
+srpHAReadOnlyJNDI {
+ org.jboss.security.srp.jaas.SRPLoginModule required
+ srpServerJndiName="srp-readonly/SRPServerInterfaceHA"
+ java.naming.factory.initial="org.jboss.naming.HttpNamingContextFactory"
+ java.naming.provider.url="http://localhost:8080/invoker/ReadOnlyJNDIFactoryHA"
+ ;
+
+ org.jboss.security.ClientLoginModule required
+ password-stacking="useFirstPass"
+ ;
+};
+
+other {
+ // Put your login modules that work without jBoss here
+
+ // jBoss LoginModule
+ org.jboss.security.ClientLoginModule required;
+
+ // Put your login modules that need jBoss here
+};
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/example.keystore
===================================================================
(Binary files differ)
Property changes on: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/example.keystore
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/jndi.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/jndi.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/jndi.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,4 @@
+### JBossNS properties
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.properties
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.properties (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.properties 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,9 @@
+
+log4j.rootCategory=DEBUG, Console
+
+### The console appender
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+log4j.appender.Console.Threshold=INFO
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.ConversionPattern=[%p,%c{1}] %m%n
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/log4j.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p,%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <level value ="DEBUG"/>
+ <appender-ref ref="CONSOLE" />
+ </root>
+</log4j:configuration>
+
Added: projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/misc-ex1-bindings.xml
===================================================================
--- projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/misc-ex1-bindings.xml (rev 0)
+++ projects/docs/enterprise/5.0/Examples/admin-config-guide-examples/src/resources/misc-ex1-bindings.xml 2009-10-14 03:55:37 UTC (rev 94809)
@@ -0,0 +1,813 @@
+<service-bindings>
+
+ <!-- ********************************************************** -->
+ <!-- * jboss0 * -->
+ <!-- ********************************************************** -->
+ <server name="jboss0">
+
+ <!-- ********************* jboss-service.xml ****************** -->
+
+ <service-config name="jboss:service=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1098</attribute>
+ </delegate-config>
+ <binding port="1099" host="${jboss.bind.address}"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=WebService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="8083"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=jrmp"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4444"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooled"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4445"/>
+ </service-config>
+
+
+ <!-- ********************* cluster-service.xml **************** -->
+
+ <service-config name="jboss:service=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1101</attribute>
+ </delegate-config>
+ <binding port="1100" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=jrmpha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4444"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooledha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4448"/>
+ </service-config>
+
+ <!-- ********************* iiop-service.xml ****************** -->
+
+ <service-config name="jboss:service=CorbaORB"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="3528"/>
+ </service-config>
+
+
+ <!-- ********************* jmx-rmi-adaptor.sar **************** -->
+
+ <service-config name="jboss.jmx:type=Connector,name=RMI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="19001"/>
+ </service-config>
+
+
+ <!-- ********************* snmp-adaptor.sar ****************** -->
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1162"/>
+ </service-config>
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1161"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-service.xml **************** -->
+
+ <!-- JMS related services -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8093"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-httpil.sar **************** -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="URLPort"/>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- ********************* hajndi-jms-ds.xml **************** -->
+
+ <!-- The JMS provider loader -->
+ <service-config name="jboss.jms:service=JMSProviderLoader,name=HAJNDIJMSProvider"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <!--
+ MAKE SURE java.naming.provider.url
+ PORT IS SAME AS HA-JNDI ABOVE !!!
+ -->
+ <delegate-config>
+ <attribute name="Properties"><![CDATA[
+ java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+ java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+ java.naming.provider.url=${jboss.bind.address:localhost}:1100
+ jnp.disableDiscovery=false
+ jnp.partitionName=${jboss.partition.name:DefaultPartition}
+ jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
+ jnp.discoveryPort=1102
+ jnp.discoveryTTL=16
+ jnp.discoveryTimeout=5000
+ jnp.maxRetries=1
+ ]]>
+ </attribute>
+ </delegate-config>
+ <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
+ BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
+ <binding port="1100"/>
+ </service-config>
+
+ <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
+ <!-- EJBInvoker -->
+ <service-config name="jboss:service=invoker,type=http"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->
+
+ <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873</attribute>
+ </delegate-config>
+ <binding port="3873"/>
+ </service-config>
+
+ <!-- JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- readonly JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- **************** httpha-invoker.sar*************** -->
+ <!-- EJBInvokerHA -->
+ <service-config name="jboss:service=invoker,type=httpHA"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- JMXInvokerHA -->
+ <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+
+ <!-- ********************* jboss-ws4ee.sar **************** -->
+
+ <!-- Web Service related services -->
+ <service-config name="jboss.ws4ee:service=AxisService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
+ <binding port="8080" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <!-- ********************* remoting **************** -->
+
+ <!-- *** remoting connector *** -->
+ <service-config name="jboss.remoting:service=Connector,transport=socket"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
+ <delegate-config>
+ <xslt-config configName="Configuration"><![CDATA[
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="attribute[@name='serverBindPort']">
+ <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="4446" />
+ </service-config>
+
+
+ <!-- ********************* hsqldb-ds.xml ********************** -->
+
+ <!-- Hypersonic related services when using the tcp/ip access
+ <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="host"/>
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="config-property[@name='ConnectionURL']">
+ <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
+]]>
+ </xslt-config>
+ </delegate-config>
+ <binding host="localhost" port="1701" />
+ </service-config>
+
+ <service-config name="jboss:service=Hypersonic"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" />
+ <binding port="1701" />
+ </service-config>
+ -->
+
+
+ <!-- ********************* tomcat ********************** -->
+
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTFileDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ConfigFile"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- ********************* jboss messaging ********************** -->
+
+ <service-config name="jboss.messaging:service=Connector,transport=bisocket"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="Configuration"><![CDATA[
+ <config>
+ <invoker transport="bisocket">
+ <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="dataType" isParam="true">jms</attribute>
+ <attribute name="socket.check_connection" isParam="true">false</attribute>
+ <attribute name="timeout" isParam="true">0</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">4457</attribute>
+ <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+ <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+ <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+ <attribute name="pingFrequency" isParam="true">214748364</attribute>
+ <attribute name="pingWindowFactor" isParam="true">10</attribute>
+ <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+ <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+ <attribute name="numberOfRetries" isParam="true">10</attribute>
+ <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+ </handlers>
+ </config>
+ ]]></attribute>
+ </delegate-config>
+ <binding port="4457"/>
+ </service-config>
+
+ </server>
+
+ <!-- ********************************************************** -->
+ <!-- * jboss1 * -->
+ <!-- ********************************************************** -->
+ <server name="jboss1">
+
+ <!-- EJB3 Remoting Connector ejb3.deployer/META-INF/jboss-service.xml -->
+
+ <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="InvokerLocator">socket://${jboss.bind.address}:3973</attribute>
+ </delegate-config>
+ <binding port="3973"/>
+ </service-config>
+
+ <!-- ********************* jboss-service.xml ****************** -->
+
+ <service-config name="jboss:service=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1198</attribute>
+ </delegate-config>
+ <binding port="1199" host="${jboss.bind.address}"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=WebService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="8183"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=jrmp"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4544"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=pooled"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4545"/>
+ </service-config>
+
+
+ <!-- ********************* cluster-service.xml **************** -->
+
+ <service-config name="jboss:service=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1201</attribute>
+ </delegate-config>
+ <binding port="1200" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=jrmpha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4544"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooledha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4548"/>
+ </service-config>
+
+ <!-- ********************* iiop-service.xml ****************** -->
+
+ <service-config name="jboss:service=CorbaORB"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="3628"/>
+ </service-config>
+
+
+ <!-- ********************* jmx-rmi-adaptor.sar **************** -->
+
+ <service-config name="jboss.jmx:type=Connector,name=RMI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="19101"/>
+ </service-config>
+
+
+ <!-- ********************* snmp-adaptor.sar ****************** -->
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1262"/>
+ </service-config>
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1261"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-service.xml **************** -->
+
+ <!-- JMS related services -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8193"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-httpil.sar **************** -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="URLPort"/>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- ********************* hajndi-jms-ds.xml **************** -->
+
+ <!-- The JMS provider loader -->
+ <service-config name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <!--
+ MAKE SURE java.naming.provider.url
+ PORT IS SAME AS HA-JNDI ABOVE !!!
+ -->
+ <delegate-config>
+ <attribute name="Properties"><![CDATA[
+ java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+ java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+ java.naming.provider.url=${jboss.bind.address:localhost}:1200
+ jnp.disableDiscovery=false
+ jnp.partitionName=${jboss.partition.name:DefaultPartition}
+ jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
+ jnp.discoveryPort=1102
+ jnp.discoveryTTL=16
+ jnp.discoveryTimeout=5000
+ jnp.maxRetries=1
+ ]]>
+ </attribute>
+ </delegate-config>
+ <!-- NOTE: YOU MUST ADD THIS ELEMENT, BUT THE VALUE DOESN'T MATTER
+ BE SURE THE CORRECT VALUE IS IN java.naming.provider.url ABOVE -->
+ <binding port="1200"/>
+ </service-config>
+
+ <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
+ <!-- EJBInvoker -->
+ <service-config name="jboss:service=invoker,type=http"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- readonly JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- **************** httpha-invoker.sar*************** -->
+ <!-- EJBInvokerHA -->
+ <service-config name="jboss:service=invoker,type=httpHA"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- JMXInvokerHA -->
+ <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+
+
+
+ <!-- ********************* jboss-ws4ee.sar **************** -->
+
+ <!-- Web Service related services -->
+ <service-config name="jboss.ws4ee:service=AxisService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="WebServicePort" hostName="WebServiceHost"/>
+ <binding port="8180" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <!-- ********************* remoting **************** -->
+
+ <!-- *** remoting connector *** -->
+ <service-config name="jboss.remoting:service=Connector,transport=socket"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
+ <delegate-config>
+ <xslt-config configName="Configuration"><![CDATA[
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="attribute[@name='serverBindPort']">
+ <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="5446" />
+ </service-config>
+
+ <!-- ********************* hsqldb-ds.xml ********************** -->
+
+ <!-- Hypersonic related services
+
+ Only if using TCP setup (local file setup by default)
+
+ <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="host"/>
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="config-property[@name='ConnectionURL']">
+ <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
+]]>
+ </xslt-config>
+ </delegate-config>
+ <binding host="localhost" port="1801" />
+ </service-config>
+
+ <service-config name="jboss:service=Hypersonic"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" />
+ <binding port="1801" />
+ </service-config>
+
+ -->
+
+
+ <!-- ********************* tomcat ********************** -->
+
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTFileDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ConfigFile"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- ********************* jboss messaging ********************** -->
+
+ <service-config name="jboss.messaging:service=Connector,transport=bisocket"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="Configuration"><![CDATA[
+ <config>
+ <invoker transport="bisocket">
+ <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="dataType" isParam="true">jms</attribute>
+ <attribute name="socket.check_connection" isParam="true">false</attribute>
+ <attribute name="timeout" isParam="true">0</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">4557</attribute>
+ <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+ <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+ <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+ <attribute name="pingFrequency" isParam="true">214748364</attribute>
+ <attribute name="pingWindowFactor" isParam="true">10</attribute>
+ <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+ <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+ <attribute name="numberOfRetries" isParam="true">10</attribute>
+ <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+ </handlers>
+ </config>
+ ]]></attribute>
+ </delegate-config>
+ <binding port="4557"/>
+ </service-config>
+
+ </server>
+
+</service-bindings>
More information about the jboss-cvs-commits
mailing list