You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2015/04/15 18:53:38 UTC

[01/12] tomee git commit: TOMEE-1547 allow resources to be loaded more lazily, support @PostConstruct and @PreDestroy in resources

Repository: tomee
Updated Branches:
  refs/heads/master 7b9f898b7 -> 25469731e


TOMEE-1547 allow resources to be loaded more lazily, support @PostConstruct and @PreDestroy in resources

Conflicts:
	container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
	container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
	container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
	container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/LazyResourceTest.java


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/638bfcb1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/638bfcb1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/638bfcb1

Branch: refs/heads/master
Commit: 638bfcb165f270f5c0dfda28bf887084ecb5ad29
Parents: b14e149
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 09:59:19 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:58:11 2015 +0100

----------------------------------------------------------------------
 .../arquillian/tests/resource/ResourceTest.java | 117 ++++++++++++++++++
 .../src/test/resources/META-INF/resources.xml   |  37 ++++++
 .../openejb/assembler/classic/Assembler.java    | 121 +++++++++++++++++--
 .../apache/openejb/config/DeploymentLoader.java |   1 +
 .../apache/openejb/config/ReadDescriptors.java  |  39 +++++-
 .../openejb/config/ReadDescriptorsTest.java     | 115 ++++++++++++++++++
 6 files changed, 417 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
new file mode 100644
index 0000000..dabc13b
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.openejb.arquillian.tests.resource;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+
+import org.apache.openejb.api.resource.DestroyableResource;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class ResourceTest {
+
+    @EJB
+    private TestEjb ejb;
+
+    @Deployment
+    public static EnterpriseArchive createDeployment() {
+
+        final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "test-ejb.jar")
+                .addAsResource("META-INF/resources.xml", "META-INF/resources.xml")
+                .addClass(ResourceTest.class)
+                .addClass(Destroyable.class)
+                .addClass(Hello.class)
+                .addClass(TestEjb.class);
+
+        final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
+                .addAsModule(ejbJar);
+
+        return ear;
+    }
+
+    @Test
+    public void test() throws Exception {
+        Assert.assertTrue(ejb.isPostConstructCalled());
+    }
+
+    @Singleton
+    @Lock(LockType.READ)
+    public static class TestEjb {
+
+        @Resource(name = "test/Hello")
+        private Hello hello;
+
+        public boolean isPostConstructCalled() {
+            return hello.isPostConstructCalled();
+        }
+    }
+
+    public static class Hello {
+
+        private boolean postConstructCalled = false;
+        private boolean preDestroyCalled = false;
+
+        @PostConstruct
+        public void postConstruct() {
+            postConstructCalled = true;
+        }
+
+        @PreDestroy
+        public void preDestroy() {
+            preDestroyCalled = true;
+        }
+
+        public boolean isPostConstructCalled() {
+            return postConstructCalled;
+        }
+
+        public boolean isPreDestroyCalled() {
+            return preDestroyCalled;
+        }
+    }
+
+    public static class Destroyable implements DestroyableResource {
+
+        private boolean destroyCalled = false;
+
+        @Override
+        public void destroyResource() {
+            destroyCalled = true;
+        }
+
+        public boolean isDestroyCalled() {
+            return destroyCalled;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/resources/META-INF/resources.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/resources/META-INF/resources.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/resources/META-INF/resources.xml
new file mode 100644
index 0000000..0249b91
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/resources/META-INF/resources.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<Resources>
+  <Resource id="Hello" class-name="org.apache.openejb.arquillian.tests.resource.ResourceTest$Hello">
+    code org.apache.openejb.arquillian.tests.resource.ResourceTest.Hello
+    Lazy true
+    UseAppClassLoader true
+    InitializeAfterDeployment true
+  </Resource>
+
+  <Resource id="Destroyable" class-name="org.apache.openejb.arquillian.tests.resource.ResourceTest$Destroyable">
+    code org.apache.openejb.arquillian.tests.resource.ResourceTest.Destroyable
+    Lazy true
+    UseAppClassLoader true
+    InitializeAfterDeployment true
+  </Resource>
+
+</Resources>
+

http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index c577ff3..9dbe0ca 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -68,6 +68,7 @@ import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.NewLoaderLogic;
 import org.apache.openejb.config.QuickJarsTxtParser;
 import org.apache.openejb.config.TldScanner;
+import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.core.ConnectorReference;
 import org.apache.openejb.core.CoreContainerSystem;
 import org.apache.openejb.core.CoreUserTransaction;
@@ -138,6 +139,7 @@ import org.apache.openejb.util.proxy.ProxyFactory;
 import org.apache.openejb.util.proxy.ProxyManager;
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.inject.OWBInjector;
 import org.apache.webbeans.logger.JULLoggerFactory;
 import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.ContainerLifecycle;
@@ -156,8 +158,8 @@ import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
 import org.apache.xbean.recipe.UnsetPropertiesRecipe;
 
-import javax.annotation.Resource;
-import javax.ejb.EJB;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
@@ -191,6 +193,7 @@ import javax.transaction.TransactionSynchronizationRegistry;
 import javax.validation.ValidationException;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
+
 import java.io.ByteArrayInputStream;
 import java.io.Externalizable;
 import java.io.File;
@@ -199,9 +202,11 @@ import java.io.InputStream;
 import java.io.InvalidObjectException;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
@@ -689,9 +694,9 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         }
 
         Extensions.addExtensions(classLoader, appInfo.eventClassesNeedingAppClassloader);
-
         logger.info("createApplication.start", appInfo.path);
-
+        final Context containerSystemContext = containerSystem.getJNDIContext();
+        
         // To start out, ensure we don't already have any beans deployed with duplicate IDs.  This
         // is a conflict we can't handle.
         final List<String> used = new ArrayList<String>();
@@ -745,8 +750,6 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
 
             appContext.set(AsynchronousPool.class, AsynchronousPool.create(appContext));
 
-            final Context containerSystemContext = containerSystem.getJNDIContext();
-
             final Map<String, LazyValidatorFactory> lazyValidatorFactories = new HashMap<String, LazyValidatorFactory>();
             final Map<String, LazyValidator> lazyValidators = new HashMap<String, LazyValidator>();
             final boolean isGeronimo = SystemInstance.get().hasProperty("openejb.geronimo");
@@ -977,6 +980,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                 }
             }
 
+            postConstructResources(appInfo, classLoader, containerSystemContext, appContext);
+            
             deployedApplications.put(appInfo.path, appInfo);
             resumePersistentSchedulers(appContext);
 
@@ -1091,6 +1096,66 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         }
     }
 
+    private void postConstructResources(final AppInfo appInfo, final ClassLoader classLoader, final Context containerSystemContext, final AppContext appContext) throws NamingException, OpenEJBException {
+        final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+
+        try {
+            Thread.currentThread().setContextClassLoader(classLoader);
+
+            final Set<String> resourceIds = new HashSet<String>(appInfo.resourceIds);
+            final List<ResourceInfo> resourceList = config.facilities.resources;
+
+            for (ResourceInfo resourceInfo : resourceList) {
+                if (!resourceIds.contains(resourceInfo.id)) {
+                    continue;
+                }
+
+                try {
+                    final Class<?> cls = Class.forName(resourceInfo.className, true, classLoader);
+                    final Method postConstruct = findMethodAnnotatedWith(PostConstruct.class, cls);
+                    boolean initialize = "true".equalsIgnoreCase(String.valueOf(resourceInfo.properties.remove("InitializeAfterDeployment")));
+                    if (postConstruct != null || initialize) {
+
+                        Object resource = containerSystemContext.lookup(OPENEJB_RESOURCE_JNDI_PREFIX + resourceInfo.id);
+                        if (resource instanceof LazyResource) {
+                            resource = LazyResource.class.cast(resource).getObject();
+                        }
+
+                        try {
+                            // wire up CDI
+                            OWBInjector.inject(appContext.getBeanManager(),
+                                    resource,
+                                    appContext.getBeanManager().createCreationalContext(null));
+
+                            if (postConstruct != null) {
+                                postConstruct.invoke(resource);
+                            }
+                        } catch (Exception e) {
+                            logger.fatal("Error calling @PostConstruct method on " + resource.getClass().getName());
+                            throw new OpenEJBException(e);
+                        }
+                    }
+                } catch (Exception e) {
+                    logger.fatal("Error calling @PostConstruct method on " + resourceInfo.id);
+                    throw new OpenEJBException(e);
+                }
+            }
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCl);
+        }
+    }
+
+    private Method findMethodAnnotatedWith(final Class<? extends Annotation> annotation, final Class<?> cls) {
+        final Method[] methods = cls.getDeclaredMethods();
+        for (final Method method : methods) {
+            if (method.getAnnotation(annotation) != null) {
+                return method;
+            }
+        }
+
+        return null;
+    }
+
     public static void mergeServices(final AppInfo appInfo) throws URISyntaxException {
         // used lazily by JaxWsServiceObjectFactory so merge both to keep same config
         // note: we could do the same for resources
@@ -1752,6 +1817,9 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             } catch (final RuntimeException e) {
                 logger.error(e.getMessage(), e);
             }
+        } else if (hasPreDestroy(object)) {
+            logger.debug("Calling @PreDestroy on: " + className);
+            preDestroy(object);
         } else if (logger.isDebugEnabled() && !DataSource.class.isInstance(object)) {
             logger.debug("Not processing resource on destroy: " + className);
         }
@@ -1772,6 +1840,31 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         }
     }
 
+    private void preDestroy(Object object) {
+        final Method preDestroy = findMethodAnnotatedWith(PreDestroy.class, object.getClass());
+        if (preDestroy != null) {
+            try {
+                preDestroy.invoke(object);
+            } catch (Exception e) {
+                logger.error("Error when calling @PreDestroy", e);
+            }
+        }
+    }
+
+    private boolean hasPreDestroy(final Object object) {
+        try {
+            Object resource = object;
+            if (resource instanceof LazyResource) {
+                resource = LazyResource.class.cast(resource).getObject();
+            }
+
+            Class<? extends Object> cls = resource.getClass();
+            return findMethodAnnotatedWith(PreDestroy.class, cls) != null;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     public void destroyApplication(final String filePath) throws UndeployException, NoSuchApplicationException {
 
         final ReentrantLock l = lock;
@@ -2475,13 +2568,21 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         return new LazyResource(new Callable<Object>() {
             @Override
             public Object call() throws Exception {
-                final Thread t = Thread.currentThread();
-                t.setContextClassLoader(loader);
-                final ClassLoader old = t.getContextClassLoader();
+                final boolean appClassLoader = "true".equals(serviceInfo.properties.remove("UseAppClassLoader"));
+
+                ClassLoader old = null;
+
+                if (!appClassLoader) {
+                    old = Thread.currentThread().getContextClassLoader();
+                    Thread.currentThread().setContextClassLoader(loader);
+                }
+
                 try {
                     return doCreateResource(serviceInfo);
                 } finally {
-                    t.setContextClassLoader(old);
+                    if (old != null) {
+                        Thread.currentThread().setContextClassLoader(old);
+                    }
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 5ff4034..6336f33 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -26,6 +26,7 @@ import org.apache.openejb.cdi.CompositeBeans;
 import org.apache.openejb.classloader.ClassLoaderConfigurer;
 import org.apache.openejb.classloader.WebAppEnricher;
 import org.apache.openejb.config.event.BeforeDeploymentEvent;
+import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.config.sys.Resources;
 import org.apache.openejb.core.EmptyResourcesClassLoader;
 import org.apache.openejb.core.ParentClassLoaderFinder;

http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
index 6462f05..486a331 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
@@ -21,7 +21,9 @@ import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.cdi.CompositeBeans;
 import org.apache.openejb.config.sys.JSonConfigReader;
 import org.apache.openejb.config.sys.JaxbOpenejb;
+import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.config.sys.Resources;
+import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.jee.ApplicationClient;
 import org.apache.openejb.jee.Beans;
 import org.apache.openejb.jee.Connector;
@@ -73,6 +75,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -242,7 +245,6 @@ public class ReadDescriptors implements DynamicDeployer {
         }
 
         return appModule;
-
     }
 
     public static void readResourcesXml(final Module module) {
@@ -251,7 +253,7 @@ public class ReadDescriptors implements DynamicDeployer {
             if (url != null) {
                 try {
                     final Resources openejb = JaxbOpenejb.unmarshal(Resources.class, url.get());
-                    module.initResources(openejb);
+                    module.initResources(check(openejb));
                 } catch (final Exception e) {
                     logger.warning("can't read " + url.toString() + " to load resources for module " + module.toString(), e);
                 }
@@ -262,7 +264,7 @@ public class ReadDescriptors implements DynamicDeployer {
             if (url != null) {
                 try {
                     final Resources openejb = JSonConfigReader.read(Resources.class, url.get());
-                    module.initResources(openejb);
+                    module.initResources(check(openejb));
                 } catch (final Exception e) {
                     logger.warning("can't read " + url.toString() + " to load resources for module " + module.toString(), e);
                 }
@@ -270,6 +272,37 @@ public class ReadDescriptors implements DynamicDeployer {
         }
     }
 
+    public static Resources check(final Resources resources) {
+        final List<Resource> resourceList = resources.getResource();
+        for (final Resource resource : resourceList) {
+            if (resource.getClassName() != null) {
+                try {
+                    ParentClassLoaderFinder.Helper.get().loadClass(resource.getClassName());
+                    if (resource.getType() != null) {
+                        ParentClassLoaderFinder.Helper.get().loadClass(resource.getType());
+                    }
+                    continue;
+                } catch (Exception e) {
+                }
+
+                // if the resource class cannot be loaded,
+                // set the lazy property to true
+                // and the app classloader property to true
+
+                final Boolean lazySpecified = Boolean.valueOf(resource.getProperties().getProperty("Lazy", "false"));
+
+                resource.getProperties().setProperty("Lazy", "true");
+                resource.getProperties().setProperty("UseAppClassLoader", "true");
+
+                if (!lazySpecified) {
+                    resource.getProperties().setProperty("InitializeAfterDeployment", "true");
+                }
+            }
+        }
+
+        return resources;
+    }
+
     private void readValidationConfigType(final Module module) throws OpenEJBException {
         if (module.getValidationConfig() != null) {
             return;

http://git-wip-us.apache.org/repos/asf/tomee/blob/638bfcb1/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
new file mode 100644
index 0000000..7413109
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.config;
+
+
+import org.apache.openejb.config.sys.Resource;
+import org.apache.openejb.config.sys.Resources;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ReadDescriptorsTest {
+
+    @Test
+    public void testClassNotAvailable() {
+
+        final Resource resource = new Resource();
+        resource.setClassName("not.a.real.Class");
+
+        final Resources resources = new Resources();
+        resources.add(resource);
+
+        final Resources checkedResources = ReadDescriptors.check(resources);
+        final Resource res = checkedResources.getResource().get(0);
+
+        Assert.assertEquals("true", res.getProperties().getProperty("Lazy"));
+        Assert.assertEquals("true", res.getProperties().getProperty("UseAppClassLoader"));
+        Assert.assertEquals("true", res.getProperties().getProperty("InitializeAfterDeployment"));
+    }
+
+    @Test
+    public void testTypeNotAvailable() {
+
+        final Resource resource = new Resource();
+        resource.setClassName("org.apache.openejb.config.ReadDescriptorsTest");
+        resource.setType("not.a.real.Class");
+
+        final Resources resources = new Resources();
+        resources.add(resource);
+
+        final Resources checkedResources = ReadDescriptors.check(resources);
+        final Resource res = checkedResources.getResource().get(0);
+
+        Assert.assertEquals("true", res.getProperties().getProperty("Lazy"));
+        Assert.assertEquals("true", res.getProperties().getProperty("UseAppClassLoader"));
+        Assert.assertEquals("true", res.getProperties().getProperty("InitializeAfterDeployment"));
+    }
+
+    @Test
+    public void testClassAndTypeAvailable() {
+
+        final Resource resource = new Resource();
+        resource.setClassName("org.apache.openejb.config.ReadDescriptorsTest");
+        resource.setType("org.apache.openejb.config.ReadDescriptorsTest");
+
+        final Resources resources = new Resources();
+        resources.add(resource);
+
+        final Resources checkedResources = ReadDescriptors.check(resources);
+        final Resource res = checkedResources.getResource().get(0);
+
+        Assert.assertNull(res.getProperties().getProperty("Lazy"));
+        Assert.assertNull(res.getProperties().getProperty("UseAppClassLoader"));
+        Assert.assertNull(res.getProperties().getProperty("InitializeAfterDeployment"));
+    }
+
+    @Test
+    public void testClassAvailable() {
+
+        final Resource resource = new Resource();
+        resource.setClassName("org.apache.openejb.config.ReadDescriptorsTest");
+
+        final Resources resources = new Resources();
+        resources.add(resource);
+
+        final Resources checkedResources = ReadDescriptors.check(resources);
+        final Resource res = checkedResources.getResource().get(0);
+
+        Assert.assertNull(res.getProperties().getProperty("Lazy"));
+        Assert.assertNull(res.getProperties().getProperty("UseAppClassLoader"));
+        Assert.assertNull(res.getProperties().getProperty("InitializeAfterDeployment"));
+    }
+
+    @Test
+    public void testLazyResource() {
+        final Resource resource = new Resource();
+        resource.setClassName("not.a.real.Class");
+        resource.setType("not.a.real.Class");
+        resource.getProperties().setProperty("Lazy", "true");
+
+        final Resources resources = new Resources();
+        resources.add(resource);
+
+        final Resources checkedResources = ReadDescriptors.check(resources);
+        final Resource res = checkedResources.getResource().get(0);
+
+        Assert.assertEquals("true", res.getProperties().getProperty("Lazy"));
+        Assert.assertEquals("true", res.getProperties().getProperty("UseAppClassLoader"));
+        Assert.assertNull(res.getProperties().getProperty("InitializeAfterDeployment"));
+    }
+
+}


[09/12] tomee git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tomee

Posted by jg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tomee


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5296d4e6
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5296d4e6
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5296d4e6

Branch: refs/heads/master
Commit: 5296d4e65d6dca54470c3eb44d06c9c3472dfc0d
Parents: 6f968ca 7b9f898
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 17:51:18 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 17:51:18 2015 +0100

----------------------------------------------------------------------
 .../arquillian/common/TestClassDiscoverer.java  |  1 +
 .../org/apache/openejb/config/AutoConfig.java   | 31 ++++++++------------
 .../config/BuiltInEnvironmentEntries.java       | 11 +++----
 .../openejb/config/MergeWebappJndiContext.java  |  6 ++++
 4 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------



[07/12] tomee git commit: Fix build issue

Posted by jg...@apache.org.
Fix build issue


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e8150bbe
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e8150bbe
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e8150bbe

Branch: refs/heads/master
Commit: e8150bbe5fac9eb435733c323c349c7889e5a582
Parents: 3535548
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 11:47:30 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 12:00:04 2015 +0100

----------------------------------------------------------------------
 examples/resources-jmx-example/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/e8150bbe/examples/resources-jmx-example/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/pom.xml b/examples/resources-jmx-example/pom.xml
index 7a44815..4898c9e 100644
--- a/examples/resources-jmx-example/pom.xml
+++ b/examples/resources-jmx-example/pom.xml
@@ -66,7 +66,7 @@
       <dependency>
         <groupId>org.superbiz</groupId>
         <artifactId>resources-jmx-ejb</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1.1-SNAPSHOT</version>
         <type>ejb</type>
         <scope>compile</scope>
       </dependency>


[12/12] tomee git commit: Missing files plus @PostConstruct/@PreDestroy docs

Posted by jg...@apache.org.
Missing files plus @PostConstruct/@PreDestroy docs


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/25469731
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/25469731
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/25469731

Branch: refs/heads/master
Commit: 25469731e697ac68e49282793761c8a08f02890f
Parents: 4d27f4c
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 16:53:42 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 17:53:06 2015 +0100

----------------------------------------------------------------------
 examples/resources-jmx-example/README.md        | 111 +++++++++++++++-
 .../resource/jmx/resources/Alternative.java     | 130 +++++++++++++++++++
 .../jmx/resources/AlternativeMBean.java         |  32 +++++
 3 files changed, 268 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/25469731/examples/resources-jmx-example/README.md
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/README.md b/examples/resources-jmx-example/README.md
index 81c5e7c..9a76cd2 100644
--- a/examples/resources-jmx-example/README.md
+++ b/examples/resources-jmx-example/README.md
@@ -241,14 +241,115 @@ Resources are typically discovered, created, and bound to JNDI very early on in
 
 The following properties can be used to change this behavior.
 
-| Property                   | Values           | Description  |
-| -------------------------- | -----|
-| Lazy                       | true/false | Creates a proxy that defers the actual instantiation of the resource until the first time it is looked up from JNDI. |
-| UseAppClassLoader          | true/false  | Forces a lazily instantiated resource to use the application classloader, instead of the classloader available when the resources were first processed. |
-| InitializeAfterDeployment  | true/false  | Forces a resource created with the Lazy property to be instantiated once the application has started, as opposed to waiting for it to be looked up. |
+| Property                   | Values           | Description |
+| -------------------------- | ---------------- | ----------- |
+| Lazy                       | true/false       | Creates a proxy that defers the actual instantiation of the resource until the first time it is looked up from JNDI. |
+| UseAppClassLoader          | true/false       | Forces a lazily instantiated resource to use the application classloader, instead of the classloader available when the resources were first processed. |
+| InitializeAfterDeployment  | true/false       | Forces a resource created with the Lazy property to be instantiated once the application has started, as opposed to waiting for it to be looked up. |
 
 By default, if TomEE encounters a custom application resource that cannot be instantiated until the application has started, it will set these three flags to `true`, unless the `Lazy` flag has been explicitly set.
 
+# PostConstruct / PreDestroy
+
+As an alternative to using a factory method, you can use @PostConstruct and @PreDestroy methods within your resource class (note that you cannot use this within a factory class) to manage any additional creation or cleanup activities. TomEE will automatically call these methods when the application is started and destroyed. Using @PostConstruct will effectively force a lazily loaded resource to be instantiated when the application is starting - in the same way that the `InitializeAfterDeployment` property does.
+
+    public class Alternative implements AlternativeMBean {
+    
+        private static Logger LOGGER = Logger.getLogger(Alternative.class.getName());
+        private Properties properties;
+    
+        @PostConstruct
+        public void postConstruct() throws MBeanRegistrationException {
+            // initialize the bean
+    
+            final String code = properties.getProperty("code");
+            final String name = properties.getProperty("name");
+    
+            requireNotNull(code);
+            requireNotNull(name);
+    
+            try {
+                final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+                final ObjectName objectName = new ObjectName(name);
+                mbs.registerMBean(this, objectName);
+            } catch (final MalformedObjectNameException e) {
+                LOGGER.severe("Malformed MBean name: " + name);
+                throw new MBeanRegistrationException(e);
+            } catch (final InstanceAlreadyExistsException e) {
+                LOGGER.severe("Instance already exists: " + name);
+                throw new MBeanRegistrationException(e);
+            } catch (final NotCompliantMBeanException e) {
+                LOGGER.severe("Class is not a valid MBean: " + code);
+                throw new MBeanRegistrationException(e);
+            } catch (final javax.management.MBeanRegistrationException e) {
+                LOGGER.severe("Error registering " + name + ", " + code);
+                throw new MBeanRegistrationException(e);
+            }
+        }
+    
+        @PreDestroy
+        public void preDestroy() throws MBeanRegistrationException {
+            final String name = properties.getProperty("name");
+            requireNotNull(name);
+    
+            try {
+                final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+                final ObjectName objectName = new ObjectName(name);
+                mbs.unregisterMBean(objectName);
+            } catch (final MalformedObjectNameException e) {
+                LOGGER.severe("Malformed MBean name: " + name);
+                throw new MBeanRegistrationException(e);
+            } catch (final javax.management.MBeanRegistrationException e) {
+                LOGGER.severe("Error unregistering " + name);
+                throw new MBeanRegistrationException(e);
+            } catch (InstanceNotFoundException e) {
+                LOGGER.severe("Error unregistering " + name);
+                throw new MBeanRegistrationException(e);
+            }
+        }
+    
+        private void requireNotNull(final String object) throws MBeanRegistrationException {
+            if (object == null) {
+                throw new MBeanRegistrationException("code property not specified, stopping");
+            }
+        }
+    
+        public Properties getProperties() {
+            return properties;
+        }
+    
+        public void setProperties(final Properties properties) {
+            this.properties = properties;
+        }
+    
+        private int count = 0;
+    
+        @Override
+        public String greet(String name) {
+            if (name == null) {
+                throw new NullPointerException("Name cannot be null");
+            }
+    
+            return "Hello, " + name;
+        }
+    
+        @Override
+        public int getCount() {
+            return count;
+        }
+    
+        @Override
+        public void setCount(int value) {
+            count = value;
+        }
+    
+        @Override
+        public void increment() {
+            count++;
+        }
+    }
+
+
 # Running
 
 Running the example can be done from maven with a simple 'mvn clean install' command run from the 'resources-jmx-example' directory.

http://git-wip-us.apache.org/repos/asf/tomee/blob/25469731/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Alternative.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Alternative.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Alternative.java
new file mode 100644
index 0000000..546c53a
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Alternative.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.resources;
+
+import org.superbiz.resource.jmx.factory.MBeanRegistrationException;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class Alternative implements AlternativeMBean {
+
+    private static Logger LOGGER = Logger.getLogger(Alternative.class.getName());
+    private Properties properties;
+
+    @PostConstruct
+    public void postConstruct() throws MBeanRegistrationException {
+        // initialize the bean
+
+        final String code = properties.getProperty("code");
+        final String name = properties.getProperty("name");
+
+        requireNotNull(code);
+        requireNotNull(name);
+
+        try {
+            final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+            final ObjectName objectName = new ObjectName(name);
+            mbs.registerMBean(this, objectName);
+        } catch (final MalformedObjectNameException e) {
+            LOGGER.severe("Malformed MBean name: " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (final InstanceAlreadyExistsException e) {
+            LOGGER.severe("Instance already exists: " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (final NotCompliantMBeanException e) {
+            LOGGER.severe("Class is not a valid MBean: " + code);
+            throw new MBeanRegistrationException(e);
+        } catch (final javax.management.MBeanRegistrationException e) {
+            LOGGER.severe("Error registering " + name + ", " + code);
+            throw new MBeanRegistrationException(e);
+        }
+    }
+
+    @PreDestroy
+    public void preDestroy() throws MBeanRegistrationException {
+        final String name = properties.getProperty("name");
+        requireNotNull(name);
+
+        try {
+            final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+            final ObjectName objectName = new ObjectName(name);
+            mbs.unregisterMBean(objectName);
+        } catch (final MalformedObjectNameException e) {
+            LOGGER.severe("Malformed MBean name: " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (final javax.management.MBeanRegistrationException e) {
+            LOGGER.severe("Error unregistering " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (InstanceNotFoundException e) {
+            LOGGER.severe("Error unregistering " + name);
+            throw new MBeanRegistrationException(e);
+        }
+    }
+
+    private void requireNotNull(final String object) throws MBeanRegistrationException {
+        if (object == null) {
+            throw new MBeanRegistrationException("code property not specified, stopping");
+        }
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(final Properties properties) {
+        this.properties = properties;
+    }
+
+    private int count = 0;
+
+    @Override
+    public String greet(String name) {
+        if (name == null) {
+            throw new NullPointerException("Name cannot be null");
+        }
+
+        return "Hello, " + name;
+    }
+
+    @Override
+    public int getCount() {
+        return count;
+    }
+
+    @Override
+    public void setCount(int value) {
+        count = value;
+    }
+
+    @Override
+    public void increment() {
+        count++;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/25469731/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/AlternativeMBean.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/AlternativeMBean.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/AlternativeMBean.java
new file mode 100644
index 0000000..65e9076
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/AlternativeMBean.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.resources;
+
+public interface AlternativeMBean {
+
+    public String greet(final String name);
+
+    public int getCount();
+
+    public void setCount(int count);
+
+    public void increment();
+
+}


[04/12] tomee git commit: Look this up lazily

Posted by jg...@apache.org.
Look this up lazily


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/48fe4caa
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/48fe4caa
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/48fe4caa

Branch: refs/heads/master
Commit: 48fe4caa3fefe0053b52b941d7ee4246ddedc509
Parents: 15df1fe
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 10:59:32 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:58:49 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/openejb/assembler/classic/Assembler.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/48fe4caa/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 2c63f36..2ddef7b 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1757,7 +1757,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
 
     private void destroyResource(final String name, final String className, final Object object) {
 
-        final Method preDestroy = findPreDestroy(object);
+        Method preDestroy = null;
 
         if (object instanceof ResourceAdapterReference) {
             final ResourceAdapterReference resourceAdapter = (ResourceAdapterReference) object;
@@ -1817,7 +1817,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             } catch (final RuntimeException e) {
                 logger.error(e.getMessage(), e);
             }
-        } else if (preDestroy != null) {
+        } else if ((preDestroy = findPreDestroy(object)) != null) {
             logger.debug("Calling @PreDestroy on: " + className);
             try {
                 preDestroy.invoke(object);


[08/12] tomee git commit: Updating pom

Posted by jg...@apache.org.
Updating pom


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/6f968caa
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/6f968caa
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/6f968caa

Branch: refs/heads/master
Commit: 6f968caa54619e0b2a62ae3ab619cfe2f5af338e
Parents: e8150bb
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 17:50:47 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 17:50:47 2015 +0100

----------------------------------------------------------------------
 examples/pom.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/6f968caa/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 560ddfd..52088d3 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -156,6 +156,7 @@
     <module>webservice-holder</module>
     <module>moviefun</module>
     <module>moviefun-rest</module>
+    <module>resources-jmx-example</module>
   </modules>
 
   <dependencies>


[02/12] tomee git commit: TOMEE-1547 PMD/checkstyle

Posted by jg...@apache.org.
TOMEE-1547 PMD/checkstyle


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1c52f1e1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1c52f1e1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1c52f1e1

Branch: refs/heads/master
Commit: 1c52f1e10ab9feb660fb745dc5f83248af512a1d
Parents: 638bfcb
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 10:18:02 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:58:29 2015 +0100

----------------------------------------------------------------------
 .../apache/openejb/assembler/classic/Assembler.java   | 14 +++++---------
 .../org/apache/openejb/config/DeploymentLoader.java   |  2 --
 .../org/apache/openejb/config/ReadDescriptors.java    |  1 +
 3 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/1c52f1e1/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 9dbe0ca..940c6ab 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -68,7 +68,6 @@ import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.NewLoaderLogic;
 import org.apache.openejb.config.QuickJarsTxtParser;
 import org.apache.openejb.config.TldScanner;
-import org.apache.openejb.config.sys.Resource;
 import org.apache.openejb.core.ConnectorReference;
 import org.apache.openejb.core.CoreContainerSystem;
 import org.apache.openejb.core.CoreUserTransaction;
@@ -82,7 +81,6 @@ import org.apache.openejb.core.ivm.IntraVmProxy;
 import org.apache.openejb.core.ivm.naming.ContextualJndiReference;
 import org.apache.openejb.core.ivm.naming.IvmContext;
 import org.apache.openejb.core.ivm.naming.IvmJndiFactory;
-import org.apache.openejb.core.ivm.naming.JndiUrlReference;
 import org.apache.openejb.core.ivm.naming.LazyObjectReference;
 import org.apache.openejb.core.ivm.naming.Reference;
 import org.apache.openejb.core.security.SecurityContextHandler;
@@ -137,7 +135,6 @@ import org.apache.openejb.util.classloader.ClassLoaderAwareHandler;
 import org.apache.openejb.util.classloader.URLClassLoaderFirst;
 import org.apache.openejb.util.proxy.ProxyFactory;
 import org.apache.openejb.util.proxy.ProxyManager;
-import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.inject.OWBInjector;
 import org.apache.webbeans.logger.JULLoggerFactory;
@@ -206,7 +203,6 @@ import java.lang.annotation.Annotation;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
@@ -1105,7 +1101,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             final Set<String> resourceIds = new HashSet<String>(appInfo.resourceIds);
             final List<ResourceInfo> resourceList = config.facilities.resources;
 
-            for (ResourceInfo resourceInfo : resourceList) {
+            for (final ResourceInfo resourceInfo : resourceList) {
                 if (!resourceIds.contains(resourceInfo.id)) {
                     continue;
                 }
@@ -1113,7 +1109,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                 try {
                     final Class<?> cls = Class.forName(resourceInfo.className, true, classLoader);
                     final Method postConstruct = findMethodAnnotatedWith(PostConstruct.class, cls);
-                    boolean initialize = "true".equalsIgnoreCase(String.valueOf(resourceInfo.properties.remove("InitializeAfterDeployment")));
+                    final boolean initialize = "true".equalsIgnoreCase(String.valueOf(resourceInfo.properties.remove("InitializeAfterDeployment")));
                     if (postConstruct != null || initialize) {
 
                         Object resource = containerSystemContext.lookup(OPENEJB_RESOURCE_JNDI_PREFIX + resourceInfo.id);
@@ -1840,7 +1836,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         }
     }
 
-    private void preDestroy(Object object) {
+    private void preDestroy(final Object object) {
         final Method preDestroy = findMethodAnnotatedWith(PreDestroy.class, object.getClass());
         if (preDestroy != null) {
             try {
@@ -1858,7 +1854,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                 resource = LazyResource.class.cast(resource).getObject();
             }
 
-            Class<? extends Object> cls = resource.getClass();
+            final Class<? extends Object> cls = resource.getClass();
             return findMethodAnnotatedWith(PreDestroy.class, cls) != null;
         } catch (Exception e) {
             return false;
@@ -2538,7 +2534,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
     }
 
     public void createResource(final ResourceInfo serviceInfo) throws OpenEJBException {
-        Object service = "true".equalsIgnoreCase(String.valueOf(serviceInfo.properties.remove("Lazy"))) ?
+        final Object service = "true".equalsIgnoreCase(String.valueOf(serviceInfo.properties.remove("Lazy"))) ?
                 newLazyResource(serviceInfo) :
                 doCreateResource(serviceInfo);
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/1c52f1e1/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 6336f33..c90cf2c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -26,8 +26,6 @@ import org.apache.openejb.cdi.CompositeBeans;
 import org.apache.openejb.classloader.ClassLoaderConfigurer;
 import org.apache.openejb.classloader.WebAppEnricher;
 import org.apache.openejb.config.event.BeforeDeploymentEvent;
-import org.apache.openejb.config.sys.Resource;
-import org.apache.openejb.config.sys.Resources;
 import org.apache.openejb.core.EmptyResourcesClassLoader;
 import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.jee.Application;

http://git-wip-us.apache.org/repos/asf/tomee/blob/1c52f1e1/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
index 486a331..abd6dfc 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
@@ -283,6 +283,7 @@ public class ReadDescriptors implements DynamicDeployer {
                     }
                     continue;
                 } catch (Exception e) {
+                    // ignore if these classes are found in the classloader
                 }
 
                 // if the resource class cannot be loaded,


[06/12] tomee git commit: TOMEE-1547 adding example

Posted by jg...@apache.org.
TOMEE-1547 adding example


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/35355488
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/35355488
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/35355488

Branch: refs/heads/master
Commit: 35355488a740315a1cb23d1ab87d9ac539ccb415
Parents: bb8c30f
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 11:35:33 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:59:44 2015 +0100

----------------------------------------------------------------------
 examples/resources-jmx-example/pom.xml          |  90 ++++++++++++
 .../resources-jmx-ear/pom.xml                   |  45 ++++++
 .../resources-jmx-ejb/pom.xml                   | 104 ++++++++++++++
 .../resource/jmx/factory/Converter.java         | 143 +++++++++++++++++++
 .../superbiz/resource/jmx/factory/Editors.java  |  49 +++++++
 .../resource/jmx/factory/JMXBeanCreator.java    | 109 ++++++++++++++
 .../jmx/factory/MBeanRegistrationException.java |  39 +++++
 .../resource/jmx/factory/PrimitiveTypes.java    | 124 ++++++++++++++++
 .../superbiz/resource/jmx/resources/Hello.java  |  51 +++++++
 .../resource/jmx/resources/HelloMBean.java      |  32 +++++
 .../src/main/resources/META-INF/beans.xml       |   3 +
 .../src/main/resources/META-INF/resources.xml   |  27 ++++
 .../java/org/superbiz/resource/jmx/JMXTest.java | 118 +++++++++++++++
 .../src/test/resources/arquillian.xml           |  31 ++++
 14 files changed, 965 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/pom.xml b/examples/resources-jmx-example/pom.xml
new file mode 100644
index 0000000..7a44815
--- /dev/null
+++ b/examples/resources-jmx-example/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.superbiz</groupId>
+  <artifactId>resources-jmx</artifactId>
+  <packaging>pom</packaging>
+  <version>1.1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: Resources/JMX Example</name>
+  
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <version.openejb>4.7.2-SNAPSHOT</version.openejb>
+    <version.tomee>1.7.2-SNAPSHOT</version.tomee>
+    <version.openjpa>2.3.0</version.openjpa>
+  </properties>
+  
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+    <repository>
+      <id>tomcat-m2-repo</id>
+      <name>Tomcat Dev Repository</name>
+      <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+    </repository>
+  </repositories>
+  
+  <pluginRepositories>
+    <pluginRepository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.1</version>
+          <configuration>
+            <source>1.6</source>
+            <target>1.6</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>2.6</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  <modules>
+    <module>resources-jmx-ejb</module>
+    <module>resources-jmx-ear</module>
+  </modules>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.superbiz</groupId>
+        <artifactId>resources-jmx-ejb</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <type>ejb</type>
+        <scope>compile</scope>
+      </dependency>
+      <!-- Java EE6 dependencies -->
+      <dependency>
+        <groupId>org.apache.openejb</groupId>
+        <artifactId>javaee-api</artifactId>
+        <version>6.0-6</version>
+        <scope>provided</scope>
+      </dependency>
+      <!-- Test dependencies -->
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>4.11</version>
+        <type>jar</type>
+        <scope>test</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ear/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ear/pom.xml b/examples/resources-jmx-example/resources-jmx-ear/pom.xml
new file mode 100644
index 0000000..e83de66
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ear/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+	    <groupId>org.superbiz</groupId>
+	    <artifactId>resources-jmx</artifactId>
+	    <version>1.1.1-SNAPSHOT</version>
+	</parent>
+	<artifactId>resources-jmx-ear</artifactId>
+	<packaging>ear</packaging>
+	<name>OpenEJB :: Examples :: Resources/JMX Example :: EAR Module</name>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-ear-plugin</artifactId>
+				<version>2.9</version>
+				<configuration>
+					<version>6</version>
+					<defaultLibBundleDir>lib</defaultLibBundleDir>
+					<archive>
+						<manifest>
+							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+						</manifest>
+					</archive>
+					<modules>
+						<ejbModule>
+							<groupId>org.superbiz</groupId>
+							<artifactId>resources-jmx-ejb</artifactId>
+						</ejbModule>
+					</modules>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.superbiz</groupId>
+			<artifactId>resources-jmx-ejb</artifactId>
+			<type>ejb</type>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/pom.xml b/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
new file mode 100644
index 0000000..e44feb1
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+	    <groupId>org.superbiz</groupId>
+	    <artifactId>resources-jmx</artifactId>
+	    <version>1.1.1-SNAPSHOT</version>
+	</parent>
+	<artifactId>resources-jmx-ejb</artifactId>
+	<packaging>ejb</packaging>
+	<name>OpenEJB :: Examples :: Resources/JMX Example :: EJB Module</name>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-ejb-plugin</artifactId>
+				<version>2.3</version>
+				<configuration>
+					<ejbVersion>3.1</ejbVersion>
+					<archive>
+						<manifest>
+							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+						</manifest>
+					</archive>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>javaee-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>arquillian-tomee-remote</artifactId>
+			<version>${version.tomee}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>openejb-provisionning</artifactId>
+			<version>${version.openejb}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.arquillian.junit</groupId>
+			<artifactId>arquillian-junit-container</artifactId>
+			<version>1.1.7.Final</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>ziplock</artifactId>
+			<version>${version.tomee}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.shrinkwrap.resolver</groupId>
+			<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+			<version>2.2.0-beta-2</version>
+			<scope>test</scope>
+			<exclusions>
+				<exclusion>
+					<artifactId>aether-api</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>aether-impl</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>aether-spi</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>aether-util</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>aether-connector-basic</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+				<exclusion>
+					<artifactId>aether-transport-wagon</artifactId>
+					<groupId>org.eclipse.aether</groupId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-aether-provider</artifactId>
+			<version>3.0.5</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
new file mode 100644
index 0000000..07305ee
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.resource.jmx.factory;
+
+
+import java.beans.PropertyEditor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * Can convert anything with a:
+ * - PropertyEditor
+ * - Constructor that accepts String
+ * - public static method that returns itself and takes a String
+ *
+ * @version $Revision$ $Date$
+ */
+public class Converter {
+
+    private Converter() {
+    }
+
+    public static Object convert(final Object value, Class<?> targetType, final String name) {
+        if (value == null) {
+            if (targetType.equals(Boolean.TYPE)) {
+                return false;
+            }
+            return value;
+        }
+
+        final Class<? extends Object> actualType = value.getClass();
+
+        if (targetType.isPrimitive()) {
+            targetType =  PrimitiveTypes.valueOf(targetType.toString().toUpperCase()).getWraper();
+        }
+
+        if (targetType.isAssignableFrom(actualType)) {
+            return value;
+        }
+
+        if (Number.class.isAssignableFrom(actualType) && Number.class.isAssignableFrom(targetType)) {
+            return value;
+        }
+
+        if (!(value instanceof String)) {
+            final String message = String.format("Expected type '%s' for '%s'. Found '%s'", targetType.getName(), name, actualType.getName());
+            throw new IllegalArgumentException(message);
+        }
+
+        final String stringValue = (String) value;
+
+        if (Enum.class.isAssignableFrom(targetType)) {
+            final Class<? extends Enum> enumType = (Class<? extends Enum>) targetType;
+            try {
+                return Enum.valueOf(enumType, stringValue);
+            } catch (final IllegalArgumentException e) {
+                try {
+                    return Enum.valueOf(enumType, stringValue.toUpperCase());
+                } catch (final IllegalArgumentException e1) {
+                    return Enum.valueOf(enumType, stringValue.toLowerCase());
+                }
+            }
+        }
+
+        try {
+            // Force static initializers to run
+            Class.forName(targetType.getName(), true, targetType.getClassLoader());
+        } catch (final ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        final PropertyEditor editor = Editors.get(targetType);
+
+        if (editor == null) {
+            final Object result = create(targetType, stringValue);
+            if (result != null) {
+                return result;
+            }
+        }
+
+        if (editor == null) {
+            final String message = String.format("Cannot convert to '%s' for '%s'. No PropertyEditor", targetType.getName(), name);
+            throw new IllegalArgumentException(message);
+        }
+
+        editor.setAsText(stringValue);
+        return editor.getValue();
+    }
+
+    private static Object create(final Class<?> type, final String value) {
+        try {
+            final Constructor<?> constructor = type.getConstructor(String.class);
+            return constructor.newInstance(value);
+        } catch (final NoSuchMethodException e) {
+            // fine
+        } catch (final Exception e) {
+            final String message = String.format("Cannot convert string '%s' to %s.", value, type);
+            throw new IllegalArgumentException(message, e);
+        }
+
+        for (final Method method : type.getMethods()) {
+            if (isInvalidMethod(type, method)) { continue; }
+
+            try {
+                return method.invoke(null, value);
+            } catch (final Exception e) {
+                final String message = String.format("Cannot convert string '%s' to %s.", value, type);
+                throw new IllegalStateException(message, e);
+            }
+        }
+
+        return null;
+    }
+
+    private static boolean isInvalidMethod(Class<?> type, Method method) {
+        if (!Modifier.isStatic(method.getModifiers()) ||
+                !Modifier.isPublic(method.getModifiers()) ||
+                !method.getReturnType().equals(type) ||
+                !method.getParameterTypes()[0].equals(String.class) ||
+                method.getParameterTypes().length != 1)
+        {
+            return true;
+        }
+        return false;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
new file mode 100644
index 0000000..33c9fc8
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.resource.jmx.factory;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+public class Editors {
+
+    private Editors() {
+        // no-op
+    }
+
+    public static PropertyEditor get(final Class<?> type) {
+        final PropertyEditor editor = PropertyEditorManager.findEditor(type);
+
+        if (editor != null) return editor;
+
+        final Class<Editors> c = Editors.class;
+
+        try {
+            final Class<?> editorClass = c.getClassLoader().loadClass(c.getName().replace("Editors", type.getSimpleName() + "Editor"));
+
+            PropertyEditorManager.registerEditor(type, editorClass);
+
+            return PropertyEditorManager.findEditor(type);
+        } catch (final ClassNotFoundException e) {
+            return null;
+        }
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/JMXBeanCreator.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/JMXBeanCreator.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/JMXBeanCreator.java
new file mode 100644
index 0000000..311879c
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/JMXBeanCreator.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.factory;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.Field;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class JMXBeanCreator {
+
+    private static Logger LOGGER = Logger.getLogger(JMXBeanCreator.class.getName());
+    private Properties properties;
+
+    public Object create() throws MBeanRegistrationException {
+        // instantiate the bean
+
+        final String code = properties.getProperty("code");
+        final String name = properties.getProperty("name");
+
+        requireNotNull(code);
+        requireNotNull(name);
+
+        try {
+            final Class<?> cls = Class.forName(code, true, Thread.currentThread().getContextClassLoader());
+            final Object instance = cls.newInstance();
+
+            final Field[] fields = cls.getDeclaredFields();
+            for (final Field field : fields) {
+
+                final String property = properties.getProperty(field.getName());
+                if (property == null) {
+                    continue;
+                }
+
+                try {
+                    field.setAccessible(true);
+                    field.set(instance, Converter.convert(property, field.getType(), field.getName()));
+                } catch (Exception e) {
+                    LOGGER.info(String.format("Unable to set value %s on field %s", property, field.getName()));
+                }
+            }
+
+            final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+            final ObjectName objectName = new ObjectName(name);
+            mbs.registerMBean(instance, objectName);
+
+            return instance;
+
+        } catch (final ClassNotFoundException e) {
+            LOGGER.severe("Unable to find class " + code);
+            throw new MBeanRegistrationException(e);
+        } catch (final InstantiationException e) {
+            LOGGER.severe("Unable to create instance of class " + code);
+            throw new MBeanRegistrationException(e);
+        } catch (final IllegalAccessException e) {
+            LOGGER.severe("Illegal access: " + code);
+            throw new MBeanRegistrationException(e);
+        } catch (final MalformedObjectNameException e) {
+            LOGGER.severe("Malformed MBean name: " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (final InstanceAlreadyExistsException e) {
+            LOGGER.severe("Instance already exists: " + name);
+            throw new MBeanRegistrationException(e);
+        } catch (final NotCompliantMBeanException e) {
+            LOGGER.severe("Class is not a valid MBean: " + code);
+            throw new MBeanRegistrationException(e);
+        } catch (final javax.management.MBeanRegistrationException e) {
+            LOGGER.severe("Error registering " + name + ", " + code);
+            throw new MBeanRegistrationException(e);
+        }
+    }
+
+    private void requireNotNull(final String object) throws MBeanRegistrationException {
+        if (object == null) {
+            throw new MBeanRegistrationException("code property not specified, stopping");
+        }
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(final Properties properties) {
+        this.properties = properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/MBeanRegistrationException.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/MBeanRegistrationException.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/MBeanRegistrationException.java
new file mode 100644
index 0000000..a21b7ab
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/MBeanRegistrationException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.factory;
+
+public class MBeanRegistrationException extends Exception {
+
+    public MBeanRegistrationException() {
+    }
+
+    public MBeanRegistrationException(String message) {
+        super(message);
+    }
+
+    public MBeanRegistrationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public MBeanRegistrationException(Throwable cause) {
+        super(cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
new file mode 100644
index 0000000..da9e56c
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.resource.jmx.factory;
+
+public enum PrimitiveTypes {
+    BOOLEAN {
+        @Override
+        public String getDefaultValue() {
+            return "false";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Boolean.class;
+        }
+    },
+    BYTE {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Byte.class;
+        }
+    },
+    CHAR {
+        @Override
+        public String getDefaultValue() {
+            return "\u0000";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Character.class;
+        }
+    },
+    CHARACTER {
+        @Override
+        public String getDefaultValue() {
+            return "\u0000";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Character.class;
+        }
+    },
+    LONG {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Long.class;
+        }
+    },
+    FLOAT {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Float.class;
+        }
+    },
+    INT {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Integer.class;
+        }
+    },
+    DOUBLE {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Double.class;
+        }
+    },
+    SHORT {
+        @Override
+        public String getDefaultValue() {
+            return "0";
+        }
+
+        @Override
+        public Class<?> getWraper() {
+            return Short.class;
+        }
+    };
+
+    public abstract String getDefaultValue();
+    public abstract Class<?> getWraper();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
new file mode 100644
index 0000000..5b04d8f
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.resources;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class Hello implements HelloMBean {
+
+    private AtomicInteger count = new AtomicInteger(0);
+
+    @Override
+    public String greet(String name) {
+        if (name == null) {
+            throw new NullPointerException("Name cannot be null");
+        }
+
+        return "Hello, " + name;
+    }
+
+    @Override
+    public int getCount() {
+        return count.get();
+    }
+
+    @Override
+    public void setCount(int value) {
+        count.set(value);
+    }
+
+    @Override
+    public void increment() {
+        count.incrementAndGet();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/HelloMBean.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/HelloMBean.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/HelloMBean.java
new file mode 100644
index 0000000..e838353
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/HelloMBean.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx.resources;
+
+public interface HelloMBean {
+
+    public String greet(final String name);
+
+    public int getCount();
+
+    public void setCount(int count);
+
+    public void increment();
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..c659db4
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd"/>

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
new file mode 100644
index 0000000..cff5fff
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<Resources>
+  <Resource id="Hello" class-name="org.superbiz.resource.jmx.factory.JMXBeanCreator" factory-name="create">
+    code org.superbiz.resource.jmx.resources.Hello
+    name superbiz.test:name=Hello
+    count 12345
+  </Resource>
+</Resources>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java b/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
new file mode 100644
index 0000000..6a9438c
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.superbiz.resource.jmx;
+
+import org.apache.ziplock.maven.Mvn;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.resource.jmx.resources.HelloMBean;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+
+@RunWith(Arquillian.class)
+public class JMXTest {
+
+    @EJB
+    private TestEjb ejb;
+
+    @Deployment
+    public static EnterpriseArchive createDeployment() {
+
+        final JavaArchive ejbJar = new Mvn.Builder()
+                .name("jmx-ejb.jar")
+                .build(JavaArchive.class)
+                .addClass(JMXTest.class)
+                .addClass(TestEjb.class);
+
+        final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jmx.ear")
+                .addAsModule(ejbJar);
+
+        return ear;
+    }
+
+    @Test
+    public void test() throws Exception {
+        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        final ObjectName objectName = new ObjectName("superbiz.test:name=Hello");
+
+        Assert.assertNotNull(ejb);
+        
+        Assert.assertEquals(0, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(0, ejb.getCount());
+        
+        mbs.invoke(objectName, "increment", new Object[0], new String[0]);
+        Assert.assertEquals(1, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(1, ejb.getCount());
+        
+        ejb.increment();
+        Assert.assertEquals(2, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(2, ejb.getCount());
+
+        Attribute attribute = new Attribute("Count", 12345);
+        mbs.setAttribute(objectName, attribute);
+        Assert.assertEquals(12345, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(12345, ejb.getCount());
+        
+        ejb.setCount(23456);
+        Assert.assertEquals(23456, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(23456, ejb.getCount());
+
+        Assert.assertEquals("Hello, world", mbs.invoke(objectName, "greet", new Object[] { "world" }, new String[] { String.class.getName() }));
+        Assert.assertEquals("Hello, world", ejb.greet("world"));
+    }
+
+    @Singleton
+    @Lock(LockType.READ)
+    public static class TestEjb {
+
+        @Resource(name="jmx/Hello")
+        private HelloMBean helloMBean;
+
+        public String greet(String name) {
+            return helloMBean.greet(name);
+        }
+
+        public void setCount(int count) {
+            helloMBean.setCount(count);
+        }
+
+        public void increment() {
+            helloMBean.increment();
+        }
+
+        public int getCount() {
+            return helloMBean.getCount();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/35355488/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..b015420
--- /dev/null
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<arquillian>
+  <container qualifier="tomee" default="true">
+    <configuration>
+      <property name="classifier">plus</property>
+      <property name="httpPort">-1</property>
+      <property name="stopPort">-1</property>
+      <property name="tomcatVersion"></property>
+      <property name="openejbVersion">${tomee.version}</property>
+      <property name="dir">target/apache-tomee-remote</property>
+      <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+    </configuration>
+  </container>
+</arquillian>


[11/12] tomee git commit: Expanding example

Posted by jg...@apache.org.
Expanding example


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4d27f4ce
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4d27f4ce
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4d27f4ce

Branch: refs/heads/master
Commit: 4d27f4ce8663057dd8d2177b804568c6126fd10a
Parents: 52e53c1
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 16:29:18 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 17:52:50 2015 +0100

----------------------------------------------------------------------
 examples/resources-jmx-example/pom.xml          | 19 ++++++
 .../resources-jmx-ear/pom.xml                   | 19 ++++++
 .../resources-jmx-ejb/pom.xml                   | 19 ++++++
 .../resource/jmx/factory/Converter.java         |  1 +
 .../superbiz/resource/jmx/factory/Editors.java  |  1 +
 .../resource/jmx/factory/PrimitiveTypes.java    |  1 +
 .../superbiz/resource/jmx/resources/Hello.java  | 10 ++-
 .../src/main/resources/META-INF/beans.xml       | 19 ++++++
 .../src/main/resources/META-INF/resources.xml   |  9 ++-
 .../java/org/superbiz/resource/jmx/JMXTest.java | 71 ++++++++++++++++++--
 .../src/test/resources/arquillian.xml           | 33 ++++-----
 11 files changed, 173 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/pom.xml b/examples/resources-jmx-example/pom.xml
index 4898c9e..62f5d03 100644
--- a/examples/resources-jmx-example/pom.xml
+++ b/examples/resources-jmx-example/pom.xml
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ear/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ear/pom.xml b/examples/resources-jmx-example/resources-jmx-ear/pom.xml
index e83de66..df3df69 100644
--- a/examples/resources-jmx-example/resources-jmx-ear/pom.xml
+++ b/examples/resources-jmx-example/resources-jmx-ear/pom.xml
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/pom.xml b/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
index e44feb1..c84851a 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
+++ b/examples/resources-jmx-example/resources-jmx-ejb/pom.xml
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
index 07305ee..e540f4e 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Converter.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.superbiz.resource.jmx.factory;
 
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
index 33c9fc8..c39cf7e 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/Editors.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.superbiz.resource.jmx.factory;
 
 import java.beans.PropertyEditor;

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
index da9e56c..9377409 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/factory/PrimitiveTypes.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.superbiz.resource.jmx.factory;
 
 public enum PrimitiveTypes {

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
index 5b04d8f..d6b5493 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/java/org/superbiz/resource/jmx/resources/Hello.java
@@ -19,11 +19,9 @@
 
 package org.superbiz.resource.jmx.resources;
 
-import java.util.concurrent.atomic.AtomicInteger;
-
 public class Hello implements HelloMBean {
 
-    private AtomicInteger count = new AtomicInteger(0);
+    private int count = 0;
 
     @Override
     public String greet(String name) {
@@ -36,16 +34,16 @@ public class Hello implements HelloMBean {
 
     @Override
     public int getCount() {
-        return count.get();
+        return count;
     }
 
     @Override
     public void setCount(int value) {
-        count.set(value);
+        count = value;
     }
 
     @Override
     public void increment() {
-        count.incrementAndGet();
+        count++;
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
index c659db4..8af19c5 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/beans.xml
@@ -1,3 +1,22 @@
 <?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
 <beans xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd"/>

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
index cff5fff..03bd9d0 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/main/resources/META-INF/resources.xml
@@ -22,6 +22,13 @@
   <Resource id="Hello" class-name="org.superbiz.resource.jmx.factory.JMXBeanCreator" factory-name="create">
     code org.superbiz.resource.jmx.resources.Hello
     name superbiz.test:name=Hello
-    count 12345
+    count 20
   </Resource>
+
+  <Resource id="Alternative" class-name="org.superbiz.resource.jmx.resources.Alternative">
+    code org.superbiz.resource.jmx.resources.Alternative
+    name superbiz.test:name=Alternative
+    count 20
+  </Resource>
+
 </Resources>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java b/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
index 6a9438c..42fc51f 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/test/java/org/superbiz/resource/jmx/JMXTest.java
@@ -28,6 +28,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.superbiz.resource.jmx.resources.AlternativeMBean;
 import org.superbiz.resource.jmx.resources.HelloMBean;
 
 import javax.annotation.Resource;
@@ -46,6 +47,9 @@ public class JMXTest {
     @EJB
     private TestEjb ejb;
 
+    @EJB
+    private AlternativeEjb alternativeEjb;
+
     @Deployment
     public static EnterpriseArchive createDeployment() {
 
@@ -68,16 +72,16 @@ public class JMXTest {
 
         Assert.assertNotNull(ejb);
         
-        Assert.assertEquals(0, mbs.getAttribute(objectName, "Count"));
-        Assert.assertEquals(0, ejb.getCount());
+        Assert.assertEquals(20, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(20, ejb.getCount());
         
         mbs.invoke(objectName, "increment", new Object[0], new String[0]);
-        Assert.assertEquals(1, mbs.getAttribute(objectName, "Count"));
-        Assert.assertEquals(1, ejb.getCount());
+        Assert.assertEquals(21, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(21, ejb.getCount());
         
         ejb.increment();
-        Assert.assertEquals(2, mbs.getAttribute(objectName, "Count"));
-        Assert.assertEquals(2, ejb.getCount());
+        Assert.assertEquals(22, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(22, ejb.getCount());
 
         Attribute attribute = new Attribute("Count", 12345);
         mbs.setAttribute(objectName, attribute);
@@ -92,6 +96,37 @@ public class JMXTest {
         Assert.assertEquals("Hello, world", ejb.greet("world"));
     }
 
+    @Test
+    public void testPostConstruct() throws Exception {
+        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        final ObjectName objectName = new ObjectName("superbiz.test:name=Alternative");
+
+        Assert.assertNotNull(alternativeEjb);
+
+        Assert.assertEquals(20, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(20, alternativeEjb.getCount());
+
+        mbs.invoke(objectName, "increment", new Object[0], new String[0]);
+        Assert.assertEquals(21, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(21, alternativeEjb.getCount());
+
+        alternativeEjb.increment();
+        Assert.assertEquals(22, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(22, alternativeEjb.getCount());
+
+        Attribute attribute = new Attribute("Count", 12345);
+        mbs.setAttribute(objectName, attribute);
+        Assert.assertEquals(12345, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(12345, alternativeEjb.getCount());
+
+        alternativeEjb.setCount(23456);
+        Assert.assertEquals(23456, mbs.getAttribute(objectName, "Count"));
+        Assert.assertEquals(23456, alternativeEjb.getCount());
+
+        Assert.assertEquals("Hello, world", mbs.invoke(objectName, "greet", new Object[] { "world" }, new String[] { String.class.getName() }));
+        Assert.assertEquals("Hello, world", alternativeEjb.greet("world"));
+    }
+
     @Singleton
     @Lock(LockType.READ)
     public static class TestEjb {
@@ -115,4 +150,28 @@ public class JMXTest {
             return helloMBean.getCount();
         }
     }
+
+    @Singleton
+    @Lock(LockType.READ)
+    public static class AlternativeEjb {
+
+        @Resource(name="jmx/Alternative")
+        private AlternativeMBean alternativeMBean;
+
+        public String greet(String name) {
+            return alternativeMBean.greet(name);
+        }
+
+        public void setCount(int count) {
+            alternativeMBean.setCount(count);
+        }
+
+        public void increment() {
+            alternativeMBean.increment();
+        }
+
+        public int getCount() {
+            return alternativeMBean.getCount();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d27f4ce/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml b/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
index b015420..7466cda 100644
--- a/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
+++ b/examples/resources-jmx-example/resources-jmx-ejb/src/test/resources/arquillian.xml
@@ -1,21 +1,22 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
 <arquillian>
   <container qualifier="tomee" default="true">
     <configuration>


[10/12] tomee git commit: Headers + documentation

Posted by jg...@apache.org.
Headers + documentation


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/52e53c13
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/52e53c13
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/52e53c13

Branch: refs/heads/master
Commit: 52e53c1302f50e929ba80e8200950fda44e5599a
Parents: 5296d4e
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 13:26:27 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 17:52:20 2015 +0100

----------------------------------------------------------------------
 examples/resources-jmx-example/README.md | 629 ++++++++++++++++++++++++++
 1 file changed, 629 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/52e53c13/examples/resources-jmx-example/README.md
----------------------------------------------------------------------
diff --git a/examples/resources-jmx-example/README.md b/examples/resources-jmx-example/README.md
new file mode 100644
index 0000000..81c5e7c
--- /dev/null
+++ b/examples/resources-jmx-example/README.md
@@ -0,0 +1,629 @@
+Title: Custom resources in an EAR archive
+
+TomEE allows you to define your own resources within your application, and declare them in `META-INF/resources.xml`. This allows you do inject these resource into any managed component within your application.
+
+In addition to this, you can also define a `create` method on either the resource itself, or on a POJO that acts as a factory. This example demonstrates using the `create` method to additionally register the resource as a JMX MBean, as well as make it available for injection.
+
+## Resource
+
+Custom resource can be defined using very simple Java classes. In this particular instance, as the application also wants to register this resource as an MBean, the resource class needs to follow the MBean specification.
+
+	public class Hello implements HelloMBean {
+
+	    private AtomicInteger count = new AtomicInteger(0);
+
+	    @Override
+	    public String greet(String name) {
+	        if (name == null) {
+	            throw new NullPointerException("Name cannot be null");
+	        }
+
+	        return "Hello, " + name;
+	    }
+
+	    @Override
+	    public int getCount() {
+	        return count.get();
+	    }
+
+	    @Override
+	    public void setCount(int value) {
+	        count.set(value);
+	    }
+
+	    @Override
+	    public void increment() {
+	        count.incrementAndGet();
+	    }
+	}
+	
+	public interface HelloMBean {
+
+	    public String greet(final String name);
+
+	    public int getCount();
+
+	    public void setCount(int count);
+
+	    public void increment();
+
+	}
+
+## Create method
+
+To avoid adding the logic to register the resource as an MBean in every resource, the application provides a single class with a create() method that takes care of this logic for us.
+
+	public class JMXBeanCreator {
+
+	    private static Logger LOGGER = Logger.getLogger(JMXBeanCreator.class.getName());
+	    private Properties properties;
+
+	    public Object create() throws MBeanRegistrationException {
+	        // instantiate the bean
+
+	        final String code = properties.getProperty("code");
+	        final String name = properties.getProperty("name");
+
+	        requireNotNull(code);
+	        requireNotNull(name);
+
+	        try {
+	            final Class<?> cls = Class.forName(code, true, Thread.currentThread().getContextClassLoader());
+	            final Object instance = cls.newInstance();
+
+	            final Field[] fields = cls.getDeclaredFields();
+	            for (final Field field : fields) {
+
+	                final String property = properties.getProperty(field.getName());
+	                if (property == null) {
+	                    continue;
+	                }
+
+	                try {
+	                    field.setAccessible(true);
+	                    field.set(instance, Converter.convert(property, field.getType(), field.getName()));
+	                } catch (Exception e) {
+	                    LOGGER.info(String.format("Unable to set value %s on field %s", property, field.getName()));
+	                }
+	            }
+
+	            final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+	            final ObjectName objectName = new ObjectName(name);
+	            mbs.registerMBean(instance, objectName);
+
+	            return instance;
+
+	        } catch (final ClassNotFoundException e) {
+	            LOGGER.severe("Unable to find class " + code);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final InstantiationException e) {
+	            LOGGER.severe("Unable to create instance of class " + code);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final IllegalAccessException e) {
+	            LOGGER.severe("Illegal access: " + code);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final MalformedObjectNameException e) {
+	            LOGGER.severe("Malformed MBean name: " + name);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final InstanceAlreadyExistsException e) {
+	            LOGGER.severe("Instance already exists: " + name);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final NotCompliantMBeanException e) {
+	            LOGGER.severe("Class is not a valid MBean: " + code);
+	            throw new MBeanRegistrationException(e);
+	        } catch (final javax.management.MBeanRegistrationException e) {
+	            LOGGER.severe("Error registering " + name + ", " + code);
+	            throw new MBeanRegistrationException(e);
+	        }
+	    }
+
+	    private void requireNotNull(final String object) throws MBeanRegistrationException {
+	        if (object == null) {
+	            throw new MBeanRegistrationException("code property not specified, stopping");
+	        }
+	    }
+
+	    public Properties getProperties() {
+	        return properties;
+	    }
+
+	    public void setProperties(final Properties properties) {
+	        this.properties = properties;
+	    }
+	}
+    
+
+Note that this class uses the properties defined in the <Resource> configuration (below), combined with reflection, to instantiate the resource, and set its attributes. The code above requires two properties `code` and `name` in order to know what class to create, and the JMX name to register it under.
+
+## Resource
+
+The resource can be defined in `META-INF/resources.xml` as follows:
+
+	<Resources>
+	  <Resource id="Hello" class-name="org.superbiz.resource.jmx.factory.JMXBeanCreator" factory-name="create">
+	    code org.superbiz.resource.jmx.resources.Hello
+	    name superbiz.test:name=Hello
+	    count 12345
+	  </Resource>
+	</Resources>
+
+Note that the class-name attribute refers to the factory class, and not the resource. Once the resource has been created and bound in TomEE's JNDI tree the factory is no longer used.
+
+## Using @Resource for injection
+
+The test case for this example demonstrates injection into an EJB as one way of accessing the resource, and also accessing the resource via JMX.
+
+	@RunWith(Arquillian.class)
+	public class JMXTest {
+
+	    @EJB
+	    private TestEjb ejb;
+
+	    @Deployment
+	    public static EnterpriseArchive createDeployment() {
+
+	        final JavaArchive ejbJar = new Mvn.Builder()
+	                .name("jmx-ejb.jar")
+	                .build(JavaArchive.class)
+	                .addClass(JMXTest.class)
+	                .addClass(TestEjb.class);
+
+	        final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jmx.ear")
+	                .addAsModule(ejbJar);
+
+	        return ear;
+	    }
+
+	    @Test
+	    public void test() throws Exception {
+	        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+	        final ObjectName objectName = new ObjectName("superbiz.test:name=Hello");
+
+	        Assert.assertNotNull(ejb);
+        
+	        Assert.assertEquals(0, mbs.getAttribute(objectName, "Count"));
+	        Assert.assertEquals(0, ejb.getCount());
+        
+	        mbs.invoke(objectName, "increment", new Object[0], new String[0]);
+	        Assert.assertEquals(1, mbs.getAttribute(objectName, "Count"));
+	        Assert.assertEquals(1, ejb.getCount());
+        
+	        ejb.increment();
+	        Assert.assertEquals(2, mbs.getAttribute(objectName, "Count"));
+	        Assert.assertEquals(2, ejb.getCount());
+
+	        Attribute attribute = new Attribute("Count", 12345);
+	        mbs.setAttribute(objectName, attribute);
+	        Assert.assertEquals(12345, mbs.getAttribute(objectName, "Count"));
+	        Assert.assertEquals(12345, ejb.getCount());
+        
+	        ejb.setCount(23456);
+	        Assert.assertEquals(23456, mbs.getAttribute(objectName, "Count"));
+	        Assert.assertEquals(23456, ejb.getCount());
+
+	        Assert.assertEquals("Hello, world", mbs.invoke(objectName, "greet", new Object[] { "world" }, new String[] { String.class.getName() }));
+	        Assert.assertEquals("Hello, world", ejb.greet("world"));
+	    }
+
+	    @Singleton
+	    @Lock(LockType.READ)
+	    public static class TestEjb {
+
+	        @Resource(name="jmx/Hello")
+	        private HelloMBean helloMBean;
+
+	        public String greet(String name) {
+	            return helloMBean.greet(name);
+	        }
+
+	        public void setCount(int count) {
+	            helloMBean.setCount(count);
+	        }
+
+	        public void increment() {
+	            helloMBean.increment();
+	        }
+
+	        public int getCount() {
+	            return helloMBean.getCount();
+	        }
+	    }
+	}
+
+The name `<appname>/<resource-id>` attribute is used on the `@Resource` annotation to perform the injection. No further configuration is needed to inject the resource.
+
+# Additional properties
+
+In addition to the `code` and `name` properties that the code above uses to instantiate the resource, TomEE itself provides some
+properties to provide more control over the creation of resources.
+
+Resources are typically discovered, created, and bound to JNDI very early on in the deployment process, as other components depend on them. This may lead to problems where the final classpath for the application has not yet been determined, and therefore TomEE is unable to load your custom resource. 
+
+The following properties can be used to change this behavior.
+
+| Property                   | Values           | Description  |
+| -------------------------- | -----|
+| Lazy                       | true/false | Creates a proxy that defers the actual instantiation of the resource until the first time it is looked up from JNDI. |
+| UseAppClassLoader          | true/false  | Forces a lazily instantiated resource to use the application classloader, instead of the classloader available when the resources were first processed. |
+| InitializeAfterDeployment  | true/false  | Forces a resource created with the Lazy property to be instantiated once the application has started, as opposed to waiting for it to be looked up. |
+
+By default, if TomEE encounters a custom application resource that cannot be instantiated until the application has started, it will set these three flags to `true`, unless the `Lazy` flag has been explicitly set.
+
+# Running
+
+Running the example can be done from maven with a simple 'mvn clean install' command run from the 'resources-jmx-example' directory.
+
+When run you should see output similar to the following.
+
+	-------------------------------------------------------
+	 T E S T S
+	-------------------------------------------------------
+	Running org.superbiz.resource.jmx.JMXTest
+	Apr 15, 2015 12:40:09 PM org.jboss.arquillian.container.impl.MapObject populate
+	WARNING: Configuration contain properties not supported by the backing object org.apache.tomee.arquillian.remote.RemoteTomEEConfiguration
+	Unused property entries: {openejbVersion=${tomee.version}, tomcatVersion=}
+	Supported property names: [additionalLibs, httpPort, httpsPort, stopCommand, portRange, conf, debug, exportConfAsSystemProperty, type, unpackWars, version, serverXml, preloadClasses, dir, deployerProperties, stopPort, singleDumpByArchiveName, appWorkingDir, host, cleanOnStartUp, quickSession, ajpPort, artifactId, properties, singleDeploymentByArchiveName, groupId, stopHost, lib, catalina_opts, debugPort, webContextToUseWithEars, simpleLog, removeUnusedWebapps, keepServerXmlAsThis, classifier, bin]
+	Apr 15, 2015 12:40:09 PM org.apache.openejb.arquillian.common.Setup findHome
+	INFO: Unable to find home in: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote
+	Apr 15, 2015 12:40:09 PM org.apache.openejb.arquillian.common.MavenCache getArtifact
+	INFO: Downloading org.apache.openejb:apache-tomee:1.7.2-SNAPSHOT:zip:plus please wait...
+	Apr 15, 2015 12:40:10 PM org.apache.openejb.arquillian.common.Zips unzip
+	INFO: Extracting '/Users/jgallimore/.m2/repository/org/apache/openejb/apache-tomee/1.7.2-SNAPSHOT/apache-tomee-1.7.2-SNAPSHOT-plus.zip' to '/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote'
+	Apr 15, 2015 12:40:12 PM org.apache.tomee.arquillian.remote.RemoteTomEEContainer configure
+	INFO: Downloaded container to: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Started server process on port: 61309
+	objc[20102]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Server version:        Apache Tomcat (TomEE)/7.0.61 (1.7.2-SNAPSHOT)
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Server built:          Mar 27 2015 12:03:56 UTC
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Server number:         7.0.61.0
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: OS Name:               Mac OS X
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: OS Version:            10.9.5
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Architecture:          x86_64
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Java Home:             /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: JVM Version:           1.7.0_71-b14
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: JVM Vendor:            Oracle Corporation
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: CATALINA_BASE:         /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: CATALINA_HOME:         /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -XX:+HeapDumpOnOutOfMemoryError
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -XX:PermSize=64m
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -XX:MaxPermSize=256m
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Xmx512m
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Xms256m
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -XX:ReservedCodeCacheSize=64m
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dtomee.httpPort=61309
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dorg.apache.openejb.servlet.filters=org.apache.openejb.arquillian.common.ArquillianFilterRunner=/ArquillianServletRunner
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Djava.util.logging.config.file=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/conf/logging.properties
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -javaagent:/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/lib/openejb-javaagent.jar
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Djava.io.tmpdir=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/temp
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Djava.endorsed.dirs=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/endorsed
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dcatalina.base=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dcatalina.home=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dcatalina.ext.dirs=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/lib
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -Dorg.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+	INFO: Command line argument: -ea
+	Apr 15, 2015 12:40:14 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
+	INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/jgallimore/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
+	Apr 15, 2015 12:40:14 PM org.apache.coyote.AbstractProtocol init
+	INFO: Initializing ProtocolHandler ["http-bio-61309"]
+	Apr 15, 2015 12:40:14 PM org.apache.coyote.AbstractProtocol init
+	INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: ********************************************************************************
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: OpenEJB http://tomee.apache.org/
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: Startup: Wed Apr 15 12:40:16 BST 2015
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: Version: 4.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: Build date: 20150415
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: Build time: 11:37
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: ********************************************************************************
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: openejb.home = /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+	INFO: openejb.base = /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+	INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+	Apr 15, 2015 12:40:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+	INFO: Succeeded in installing singleton service
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory init
+	INFO: openejb configuration file is '/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/conf/tomee.xml'
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.system.apps=true'
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+	INFO: Configuring enterprise application: openejb
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+	INFO: Using openejb.deploymentId.format '{ejbName}'
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+	INFO: Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
+	Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+	INFO: Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.config.InitEjbDeployments deploy
+	INFO: Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.config.AutoConfig createContainer
+	INFO: Auto-creating a container for bean openejb/Deployer: Container(type=STATELESS, id=Default Stateless Container)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.config.AppInfoBuilder build
+	INFO: Enterprise application "openejb" loaded.
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating TransactionManager(id=Default Transaction Manager)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating SecurityService(id=Tomcat Security Service)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating Container(id=Default Stateless Container)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createAppClassLoader
+	INFO: Not creating another application classloader for openejb
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createApplication
+	INFO: Assembling app: openejb
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+	Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler deployMBean
+	INFO: Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
+	Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler createApplication
+	INFO: Deployed Application(path=openejb)
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.ServiceManager initServer
+	INFO: Creating ServerService(id=cxf)
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.ServiceManager initServer
+	INFO: Creating ServerService(id=cxf-rs)
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+	INFO:   ** Bound Services **
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager printRow
+	INFO:   NAME                 IP              PORT  
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+	INFO: -------
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+	INFO: Ready!
+	Apr 15, 2015 12:40:20 PM org.apache.catalina.startup.Catalina load
+	INFO: Initialization processed in 7621 ms
+	Apr 15, 2015 12:40:20 PM org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
+	INFO: Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
+	Apr 15, 2015 12:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating Resource(id=UserDatabase)
+	Apr 15, 2015 12:40:20 PM org.apache.catalina.core.StandardService startInternal
+	INFO: Starting service Catalina
+	Apr 15, 2015 12:40:20 PM org.apache.catalina.core.StandardEngine startInternal
+	INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.61 (1.7.2-SNAPSHOT)
+	Apr 15, 2015 12:40:21 PM org.apache.coyote.AbstractProtocol start
+	INFO: Starting ProtocolHandler ["http-bio-61309"]
+	Apr 15, 2015 12:40:21 PM org.apache.coyote.AbstractProtocol start
+	INFO: Starting ProtocolHandler ["ajp-bio-8009"]
+	Apr 15, 2015 12:40:21 PM org.apache.catalina.startup.Catalina start
+	INFO: Server startup in 247 ms
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.client.EventLogger log
+	INFO: RemoteInitialContextCreated{providerUri=http://localhost:61309/tomee/ejb}
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+	INFO: Extracting jar: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx.ear
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+	INFO: Extracted path: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+	INFO: Extracting jar: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/arquillian-protocol.war
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+	INFO: Extracted path: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/arquillian-protocol
+	Apr 15, 2015 12:40:21 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.deployments.classpath.filter.systemapps=false'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.config.DeploymentsResolver processUrls
+	INFO: Found EjbModule in classpath: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/jmx-ejb.jar
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.config.DeploymentsResolver loadFromClasspath
+	INFO: Searched 6 classpath urls in 1605 milliseconds.  Average 267 milliseconds per url.
+	Apr 15, 2015 12:40:23 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+	INFO: Configuring enterprise application: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.InitEjbDeployments deploy
+	INFO: Auto-deploying ejb TestEjb: EjbDeployment(deployment-id=TestEjb)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=jmx/Hello, type=Resource, provider-id=jmx/Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig createContainer
+	INFO: Auto-creating a container for bean jmx-ejb.Comp1256115069: Container(type=MANAGED, id=Default Managed Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating Container(id=Default Managed Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.core.managed.SimplePassivater init
+	INFO: Using directory /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-1.7.2-SNAPSHOT/temp for stateful session passivation
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'java:comp/env/jmx/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=jmx/Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig createContainer
+	INFO: Auto-creating a container for bean TestEjb: Container(type=SINGLETON, id=Default Singleton Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating Container(id=Default Singleton Container)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'java:comp/env/jmx/Hello' in bean TestEjb to Resource(id=jmx/Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean TestEjb to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean TestEjb to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean jmx_org.superbiz.resource.jmx.JMXTest to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+	INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean jmx_org.superbiz.resource.jmx.JMXTest to Resource(id=Hello)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AppInfoBuilder build
+	INFO: Enterprise application "/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx" loaded.
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createAppClassLoader
+	INFO: Creating dedicated application classloader for jmx
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createApplication
+	INFO: Assembling app: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=TestEjbLocalBean) --> Ejb(deployment-id=TestEjb)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/jmx/jmx-ejb/TestEjb!org.superbiz.resource.jmx.JMXTest$TestEjb) --> Ejb(deployment-id=TestEjb)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+	INFO: Jndi(name=global/jmx/jmx-ejb/TestEjb) --> Ejb(deployment-id=TestEjb)
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.cdi.CdiBuilder initSingleton
+	INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+	INFO: OpenWebBeans Container is starting...
+	Apr 15, 2015 12:40:24 PM org.apache.webbeans.plugins.PluginLoader startUp
+	INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+	Apr 15, 2015 12:40:24 PM org.apache.webbeans.plugins.PluginLoader startUp
+	INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
+	Apr 15, 2015 12:40:25 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+	INFO: All injection points were validated successfully.
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+	INFO: OpenWebBeans Container has started, it took 186 ms.
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Created Ejb(deployment-id=TestEjb, ejb-name=TestEjb, container=Default Singleton Container)
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+	INFO: Started Ejb(deployment-id=TestEjb, ejb-name=TestEjb, container=Default Singleton Container)
+	Apr 15, 2015 12:40:25 PM org.apache.tomee.catalina.TomcatWebAppBuilder deployWebApps
+	INFO: using default host: localhost
+	Apr 15, 2015 12:40:25 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
+	INFO: ------------------------- localhost -> /arquillian-protocol
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.util.OptionsLog info
+	INFO: Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.CdiBuilder initSingleton
+	INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+	INFO: OpenWebBeans Container is starting...
+	Apr 15, 2015 12:40:25 PM org.apache.webbeans.plugins.PluginLoader startUp
+	INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+	Apr 15, 2015 12:40:25 PM org.apache.webbeans.plugins.PluginLoader startUp
+	INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
+	Apr 15, 2015 12:40:25 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+	INFO: All injection points were validated successfully.
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+	INFO: OpenWebBeans Container has started, it took 17 ms.
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+	INFO: Creating Resource(id=jmx/Hello, aliases=Hello)
+	Apr 15, 2015 12:40:25 PM org.superbiz.resource.jmx.factory.JMXBeanCreator create
+	INFO: Unable to set value 12345 on field count
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+	WARNING: Property "code" not supported by "jmx/Hello"
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+	WARNING: Property "name" not supported by "jmx/Hello"
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+	WARNING: Property "count" not supported by "jmx/Hello"
+	Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler createApplication
+	INFO: Deployed Application(path=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx)
+	Apr 15, 2015 12:40:26 PM org.apache.openejb.client.EventLogger log
+	INFO: RemoteInitialContextCreated{providerUri=http://localhost:61309/tomee/ejb}
+	Apr 15, 2015 12:40:26 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+	INFO: Undeploying app: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+	Apr 15, 2015 12:40:27 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+	INFO: cleaning /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx.ear
+	Apr 15, 2015 12:40:27 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+	INFO: cleaning /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+	Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.464 sec
+	Apr 15, 2015 12:40:27 PM org.apache.catalina.core.StandardServer await
+	INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol pause
+	INFO: Pausing ProtocolHandler ["http-bio-61309"]
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol pause
+	INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
+	Apr 15, 2015 12:40:27 PM org.apache.catalina.core.StandardService stopInternal
+	INFO: Stopping service Catalina
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol stop
+	INFO: Stopping ProtocolHandler ["http-bio-61309"]
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol stop
+	INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
+	Apr 15, 2015 12:40:27 PM org.apache.openejb.server.SimpleServiceManager stop
+	INFO: Stopping server services
+	Apr 15, 2015 12:40:27 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+	INFO: Undeploying app: openejb
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol destroy
+	INFO: Destroying ProtocolHandler ["http-bio-61309"]
+	Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol destroy
+	INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
+
+	Results :
+
+	Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+    
+
+Note the following lines showing the creation of the resource.
+
+	Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+	INFO: Configuring Service(id=jmx/Hello, type=Resource, provider-id=jmx/Hello)
+	
+
+
+
+


[05/12] tomee git commit: TOMEE-1547 fixing test

Posted by jg...@apache.org.
TOMEE-1547 fixing test

Conflicts:
	examples/pom.xml


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bb8c30f8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bb8c30f8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bb8c30f8

Branch: refs/heads/master
Commit: bb8c30f88a6d8267dc9fe2f737590f19e0044430
Parents: 48fe4ca
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 11:25:59 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:59:31 2015 +0100

----------------------------------------------------------------------
 .../openejb/config/ReadDescriptorsTest.java     | 20 --------------------
 1 file changed, 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bb8c30f8/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
index 7413109..c8d029d 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/ReadDescriptorsTest.java
@@ -42,29 +42,10 @@ public class ReadDescriptorsTest {
     }
 
     @Test
-    public void testTypeNotAvailable() {
-
-        final Resource resource = new Resource();
-        resource.setClassName("org.apache.openejb.config.ReadDescriptorsTest");
-        resource.setType("not.a.real.Class");
-
-        final Resources resources = new Resources();
-        resources.add(resource);
-
-        final Resources checkedResources = ReadDescriptors.check(resources);
-        final Resource res = checkedResources.getResource().get(0);
-
-        Assert.assertEquals("true", res.getProperties().getProperty("Lazy"));
-        Assert.assertEquals("true", res.getProperties().getProperty("UseAppClassLoader"));
-        Assert.assertEquals("true", res.getProperties().getProperty("InitializeAfterDeployment"));
-    }
-
-    @Test
     public void testClassAndTypeAvailable() {
 
         final Resource resource = new Resource();
         resource.setClassName("org.apache.openejb.config.ReadDescriptorsTest");
-        resource.setType("org.apache.openejb.config.ReadDescriptorsTest");
 
         final Resources resources = new Resources();
         resources.add(resource);
@@ -98,7 +79,6 @@ public class ReadDescriptorsTest {
     public void testLazyResource() {
         final Resource resource = new Resource();
         resource.setClassName("not.a.real.Class");
-        resource.setType("not.a.real.Class");
         resource.getProperties().setProperty("Lazy", "true");
 
         final Resources resources = new Resources();


[03/12] tomee git commit: TOMEE-1547 Fix compile issue from merge and some slight tweaks

Posted by jg...@apache.org.
TOMEE-1547 Fix compile issue from merge and some slight tweaks


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/15df1fee
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/15df1fee
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/15df1fee

Branch: refs/heads/master
Commit: 15df1feeb23f855fb7e544a7bee3011bf5ac1861
Parents: 1c52f1e
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Apr 15 10:54:07 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Apr 15 11:58:39 2015 +0100

----------------------------------------------------------------------
 .../arquillian/tests/resource/ResourceTest.java | 18 ++++++------
 .../openejb/assembler/classic/Assembler.java    | 31 +++++++++-----------
 .../apache/openejb/config/ReadDescriptors.java  |  5 +---
 .../core/ivm/naming/LazyObjectReference.java    |  4 +++
 4 files changed, 28 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/15df1fee/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
index dabc13b..2ea59a4 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-config-tests/src/test/java/org/apache/openejb/arquillian/tests/resource/ResourceTest.java
@@ -19,15 +19,7 @@
 
 package org.apache.openejb.arquillian.tests.resource;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.ejb.Lock;
-import javax.ejb.LockType;
-import javax.ejb.Singleton;
-
-import org.apache.openejb.api.resource.DestroyableResource;
+import org.apache.openejb.api.DestroyableResource;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -37,6 +29,14 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+
 @RunWith(Arquillian.class)
 public class ResourceTest {
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/15df1fee/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 940c6ab..2c63f36 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1115,6 +1115,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                         Object resource = containerSystemContext.lookup(OPENEJB_RESOURCE_JNDI_PREFIX + resourceInfo.id);
                         if (resource instanceof LazyResource) {
                             resource = LazyResource.class.cast(resource).getObject();
+                            this.bindResource(resourceInfo.id, resource);
                         }
 
                         try {
@@ -1755,6 +1756,9 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
     }
 
     private void destroyResource(final String name, final String className, final Object object) {
+
+        final Method preDestroy = findPreDestroy(object);
+
         if (object instanceof ResourceAdapterReference) {
             final ResourceAdapterReference resourceAdapter = (ResourceAdapterReference) object;
             try {
@@ -1813,9 +1817,13 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             } catch (final RuntimeException e) {
                 logger.error(e.getMessage(), e);
             }
-        } else if (hasPreDestroy(object)) {
+        } else if (preDestroy != null) {
             logger.debug("Calling @PreDestroy on: " + className);
-            preDestroy(object);
+            try {
+                preDestroy.invoke(object);
+            } catch (final Exception e) {
+                logger.error(e.getMessage(), e);
+            }
         } else if (logger.isDebugEnabled() && !DataSource.class.isInstance(object)) {
             logger.debug("Not processing resource on destroy: " + className);
         }
@@ -1836,28 +1844,17 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         }
     }
 
-    private void preDestroy(final Object object) {
-        final Method preDestroy = findMethodAnnotatedWith(PreDestroy.class, object.getClass());
-        if (preDestroy != null) {
-            try {
-                preDestroy.invoke(object);
-            } catch (Exception e) {
-                logger.error("Error when calling @PreDestroy", e);
-            }
-        }
-    }
-
-    private boolean hasPreDestroy(final Object object) {
+    private Method findPreDestroy(final Object object) {
         try {
             Object resource = object;
-            if (resource instanceof LazyResource) {
+            if (LazyResource.class.isInstance(resource) && LazyResource.class.cast(resource).isInitialized()) {
                 resource = LazyResource.class.cast(resource).getObject();
             }
 
             final Class<? extends Object> cls = resource.getClass();
-            return findMethodAnnotatedWith(PreDestroy.class, cls) != null;
+            return findMethodAnnotatedWith(PreDestroy.class, cls);
         } catch (Exception e) {
-            return false;
+            return null;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/15df1fee/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
index abd6dfc..5f951a1 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
@@ -278,12 +278,9 @@ public class ReadDescriptors implements DynamicDeployer {
             if (resource.getClassName() != null) {
                 try {
                     ParentClassLoaderFinder.Helper.get().loadClass(resource.getClassName());
-                    if (resource.getType() != null) {
-                        ParentClassLoaderFinder.Helper.get().loadClass(resource.getType());
-                    }
                     continue;
                 } catch (Exception e) {
-                    // ignore if these classes are found in the classloader
+                    // ignore if this class is not found in the classloader
                 }
 
                 // if the resource class cannot be loaded,

http://git-wip-us.apache.org/repos/asf/tomee/blob/15df1fee/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/LazyObjectReference.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/LazyObjectReference.java b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/LazyObjectReference.java
index f4b74da..37aa6ee 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/LazyObjectReference.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/LazyObjectReference.java
@@ -43,4 +43,8 @@ public class LazyObjectReference<T> extends Reference {
         }
         return instance;
     }
+
+    public boolean isInitialized() {
+        return instance != null;
+    }
 }