[jboss-cvs] JBossAS SVN: r99035 - in projects/reloaded/trunk/naming-deployers/src: main/java/org/jboss/reloaded/naming/deployers/dependency and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 5 12:54:42 EST 2010
Author: wolfc
Date: 2010-01-05 12:54:41 -0500 (Tue, 05 Jan 2010)
New Revision: 99035
Added:
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ComponentNamingDeployer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ParentsLookupStrategy.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/DeploymentUnitInformer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEApplicationInformer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEComponentInformer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEComponent.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesDeployer.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesMetaData.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEApplicationInformer.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEComponentInformer.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEModuleInformer.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyMetaData.java
projects/reloaded/trunk/naming-deployers/src/test/resources/dummy-deployers-beans.xml
Removed:
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ApplicationLookupStrategy.java
Modified:
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/AppNamingDeployer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ModuleNamingDeployer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEModuleInformer.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEApplication.java
projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEModule.java
projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/simple/SimpleTestCase.java
projects/reloaded/trunk/naming-deployers/src/test/resources/reloaded-naming-deployers-beans.xml
Log:
RELOADED-12: added component naming deployer (WIP), fixed module path
Modified: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/AppNamingDeployer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/AppNamingDeployer.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/AppNamingDeployer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -27,20 +27,32 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.ear.spec.EarMetaData;
import org.jboss.metadata.plugins.scope.ApplicationScope;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEApplicationInformer;
import org.jboss.reloaded.naming.deployers.mc.MCJavaEEApplication;
import static org.jboss.reloaded.naming.deployers.util.AnnotationHelper.annotation;
/**
+ * The AppNamingDeployer installs a JavaEEApplication MC bean under the name of java:app
+ * within an application scope with the JavaEE application name.
+ *
+ * The JavaEEApplication MC bean will take care of initiating the java:app name space.
+ *
+ * To work properly it needs a JavaEEApplicationInformer.
+ *
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
public class AppNamingDeployer extends AbstractRealDeployer
{
- public AppNamingDeployer()
+ private JavaEEApplicationInformer informer;
+
+ public AppNamingDeployer(JavaEEApplicationInformer informer)
{
- setInputs(EarMetaData.class);
+ if(informer == null)
+ throw new NullPointerException("informer is null");
+ this.informer = informer;
+ setInputs(informer.getRequiredAttachments());
setOutputs("java:app");
setOutput(BeanMetaData.class);
}
@@ -51,7 +63,7 @@
if(!isJavaEEApplication(deploymentUnit))
return;
- String appName = getAppName(deploymentUnit);
+ String appName = informer.getApplicationName(deploymentUnit);
BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("java:app", MCJavaEEApplication.class.getName())
.addAnnotation(annotation(ApplicationScope.class, appName))
.addConstructorParameter(String.class.getName(), appName);
@@ -61,14 +73,6 @@
protected boolean isJavaEEApplication(DeploymentUnit deploymentUnit)
{
- return deploymentUnit.getSimpleName().endsWith(".ear") || deploymentUnit.getAttachment(EarMetaData.class) != null;
+ return informer.isJavaEEApplication(deploymentUnit);
}
-
- protected String getAppName(DeploymentUnit deploymentUnit)
- {
- String name = deploymentUnit.getSimpleName();
- if(name.endsWith(".ear"))
- return name.substring(0, name.length() - 4);
- return name;
- }
}
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ComponentNamingDeployer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ComponentNamingDeployer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ComponentNamingDeployer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers;
+
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.plugins.scope.ApplicationScope;
+import org.jboss.metadata.plugins.scope.DeploymentScope;
+import org.jboss.metadata.plugins.scope.InstanceScope;
+import org.jboss.reloaded.naming.deployers.dependency.ParentsLookupStrategy;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer;
+import org.jboss.reloaded.naming.deployers.mc.MCJavaEEComponent;
+import org.jboss.reloaded.naming.spi.JavaEEModule;
+
+import static org.jboss.reloaded.naming.deployers.util.AnnotationHelper.annotation;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class ComponentNamingDeployer extends AbstractRealDeployer
+{
+ private JavaEEComponentInformer informer;
+
+ public ComponentNamingDeployer(JavaEEComponentInformer informer)
+ {
+ this.informer = informer;
+ setInputs(informer.getRequiredAttachments());
+ addInput("java:module");
+ setOutput(BeanMetaData.class);
+ }
+
+ @Override
+ protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if(!informer.isJavaEEComponent(unit))
+ return;
+
+ String appName = informer.getApplicationName(unit);
+ String moduleName = informer.getModulePath(unit);
+ String name = informer.getComponentName(unit);
+
+ // create JavaEEModule bean
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("java:comp", MCJavaEEComponent.class.getName())
+ .addAnnotation(annotation(DeploymentScope.class, moduleName))
+ .addAnnotation(annotation(InstanceScope.class, name))
+ .addConstructorParameter(String.class.getName(), name);
+ AbstractInjectionValueMetaData javaModule = new AbstractInjectionValueMetaData("java:module");
+ javaModule.setSearch(new ParentsLookupStrategy());
+ builder.addConstructorParameter(JavaEEModule.class.getName(), javaModule);
+ if(appName != null)
+ builder.addAnnotation(annotation(ApplicationScope.class, appName));
+
+ unit.addAttachment(BeanMetaData.class, builder.getBeanMetaData());
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ComponentNamingDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ModuleNamingDeployer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ModuleNamingDeployer.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/ModuleNamingDeployer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -21,72 +21,81 @@
*/
package org.jboss.reloaded.naming.deployers;
-import org.jboss.beans.metadata.api.model.InjectOption;
import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.dependency.plugins.graph.ScopeKeyLookupStrategy;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.plugins.scope.ApplicationScope;
import org.jboss.metadata.plugins.scope.DeploymentScope;
-import org.jboss.metadata.spi.scope.CommonLevels;
-import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.reloaded.naming.deployers.dependency.ParentsLookupStrategy;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEModuleInformer;
import org.jboss.reloaded.naming.deployers.mc.MCJavaEEModule;
import org.jboss.reloaded.naming.spi.JavaEEApplication;
import static org.jboss.reloaded.naming.deployers.util.AnnotationHelper.annotation;
/**
+ * The ModuleNamingDeployer installs a JavaEEModule MC bean under the name of java:module
+ * within an application scope with the JavaEE application name and an deployment scope
+ * with the JavaEE module name.
+ *
+ * The JavaEEApplication MC bean will take care of initiating the java:app name space.
+ *
+ * To work properly it needs a JavaEEApplicationInformer.
+ *
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
public class ModuleNamingDeployer extends AbstractRealDeployer
{
- public ModuleNamingDeployer()
+ private JavaEEModuleInformer informer;
+
+ public ModuleNamingDeployer(JavaEEModuleInformer informer)
{
- setInputs("java:app");
+ this.informer = informer;
+ setInputs(informer.getRequiredAttachments());
+ addInput("java:app");
setOutput(BeanMetaData.class);
}
- // TODO: remove
- protected String getAppName(DeploymentUnit deploymentUnit)
- {
- String name = deploymentUnit.getTopLevel().getSimpleName();
- if(name.endsWith(".ear"))
- return name.substring(0, name.length() - 4);
- return name;
- }
-
@Override
protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
if(!isJavaEEModule(unit))
return;
- // TODO: a lot
- String appName = getAppName(unit);
- String name = unit.getSimpleName();
- name = name.substring(0, name.length() - 4);
+ // appName is either the name of the JavaEE application or null for a stand-alone JavaEE module
+ String appName = informer.getApplicationName(unit);
+ String name = informer.getModulePath(unit);
// create JavaEEModule bean
BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("java:module", MCJavaEEModule.class.getName())
.addAnnotation(annotation(DeploymentScope.class, name))
.addConstructorParameter(String.class.getName(), name);
- AbstractInjectionValueMetaData javaApp = new AbstractInjectionValueMetaData("java:app");
- javaApp.setSearch(new ScopeKeyLookupStrategy(new ScopeKey(CommonLevels.APPLICATION, appName)));
- javaApp.setInjectionOption(InjectOption.OPTIONAL);
- builder.addConstructorParameter(JavaEEApplication.class.getName(), javaApp);
+ if(appName != null)
+ {
+ builder.addAnnotation(annotation(ApplicationScope.class, appName));
+ AbstractInjectionValueMetaData javaApp = new AbstractInjectionValueMetaData("java:app");
+ javaApp.setSearch(new ParentsLookupStrategy());
+ builder.addConstructorParameter(JavaEEApplication.class.getName(), javaApp);
+ }
+ else
+ builder.addConstructorParameter(JavaEEApplication.class.getName(), (Object) null);
builder.addPropertyMetaData("nameSpaces", builder.createInject("NameSpaces"));
unit.addAttachment(BeanMetaData.class, builder.getBeanMetaData());
}
+ /**
+ * Determine whether the given deployment unit is a JavaEE module which needs
+ * a java:module name space.
+ * @param unit
+ * @return
+ */
protected boolean isJavaEEModule(DeploymentUnit unit)
{
- // TODO: a lot
- if(unit.getSimpleName().endsWith(".jar"))
- return true;
- return false;
+ return informer.getModuleType(unit) != null;
}
}
Deleted: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ApplicationLookupStrategy.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ApplicationLookupStrategy.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ApplicationLookupStrategy.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (c) 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.reloaded.naming.deployers.dependency;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.graph.LookupStrategy;
-
-/**
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class ApplicationLookupStrategy implements LookupStrategy
-{
-
- public ControllerContext getContext(Controller controller, Object name, ControllerState state)
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ParentsLookupStrategy.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ParentsLookupStrategy.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ParentsLookupStrategy.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.dependency;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.graph.AbstractLookupStrategy;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class ParentsLookupStrategy extends AbstractLookupStrategy
+{
+ @Override
+ protected ControllerContext getContextInternal(AbstractController controller, Object name, ControllerState state)
+ {
+ ControllerContext context = controller.getContext(name, state);
+ if(context != null)
+ return context;
+ AbstractController parent = controller.getParentController();
+ if (parent != null)
+ return getContextInternal(parent, name, state);
+ else
+ return null;
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/dependency/ParentsLookupStrategy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee (from rev 98333, projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/javaee)
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/DeploymentUnitInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/DeploymentUnitInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/DeploymentUnitInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.javaee;
+
+/**
+ * Obtain information about a deployment unit.
+ * The informer should only use meta data to obtain the information
+ * being asked.
+ *
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+interface DeploymentUnitInformer
+{
+ /**
+ * The required attachments for the informer to function.
+ *
+ * @return the names of the attachments
+ */
+ String[] getRequiredAttachments();
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/DeploymentUnitInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEApplicationInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEApplicationInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEApplicationInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.javaee;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Obtain information about a JavaEE application given a deployment unit.
+ * The informer should only use meta data to obtain the information
+ * being asked.
+ *
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public interface JavaEEApplicationInformer extends DeploymentUnitInformer
+{
+ /**
+ * Obtain the name of the JavaEE application for this deployment unit.
+ *
+ * @param deploymentUnit the deployment unit of the application
+ * @return the name of the JavaEE application
+ * @throws IllegalArgumentException if the deployment unit is not a JavaEE application
+ */
+ String getApplicationName(DeploymentUnit deploymentUnit) throws IllegalArgumentException;
+
+ /**
+ * Determine whether a deployment unit is a JavaEE application.
+ *
+ * @param deploymentUnit the deployment unit to analyze
+ * @return true if the deployment unit is a JavaEE application, false otherwise
+ */
+ boolean isJavaEEApplication(DeploymentUnit deploymentUnit);
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEApplicationInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEComponentInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEComponentInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEComponentInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.javaee;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public interface JavaEEComponentInformer extends JavaEEModuleInformer
+{
+ String getComponentName(DeploymentUnit unit);
+
+ boolean isJavaEEComponent(DeploymentUnit unit);
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEComponentInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEModuleInformer.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/javaee/JavaEEModuleInformer.java 2009-12-22 17:00:02 UTC (rev 98333)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/javaee/JavaEEModuleInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.jpa.javaee;
+package org.jboss.reloaded.naming.deployers.javaee;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -31,7 +31,7 @@
* @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
* @version $Revision: $
*/
-public interface JavaEEModuleInformer
+public interface JavaEEModuleInformer extends DeploymentUnitInformer
{
public enum ModuleType { APP_CLIENT, EJB, JAVA, WEB };
@@ -40,7 +40,7 @@
* example 'foo.ear'.
* If the deployment unit is not part of a JavaEE application return null.
*
- * @param deployment the deployment unit of the module, application or component
+ * @param deploymentUnit the deployment unit of the module, application or component
* @return the name of the JavaEE application or null if none
*/
String getApplicationName(DeploymentUnit deploymentUnit);
@@ -54,7 +54,7 @@
* and return the relative path within the base deployment directory.
* Note that the relative path includes the module name, for example 'lib/bar.jar'.
*
- * @param deployment the deployment unit of the module or a component
+ * @param deploymentUnit the deployment unit of the module or a component
* @return the relative path of the JavaEE module
*/
String getModulePath(DeploymentUnit deploymentUnit);
Modified: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEApplication.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEApplication.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEApplication.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -42,7 +42,7 @@
public void start() throws NamingException
{
context = nameSpaces.getGlobalContext().createSubcontext(name);
- log.info("Installed context " + context);
+ log.debug("Installed context " + context + " for JavaEE application " + name);
}
@Override
Added: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEComponent.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEComponent.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEComponent.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.mc;
+
+import org.jboss.reloaded.naming.spi.JavaEEComponent;
+import org.jboss.reloaded.naming.spi.JavaEEModule;
+import org.jnp.interfaces.NamingContext;
+import org.jnp.server.NamingServer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class MCJavaEEComponent extends AbstractNameSpace implements JavaEEComponent
+{
+ private JavaEEModule module;
+
+ public MCJavaEEComponent(String name, JavaEEModule module)
+ {
+ super(name);
+ this.module = module;
+ }
+
+ public JavaEEModule getModule()
+ {
+ return module;
+ }
+
+ @Override
+ public void start() throws Exception
+ {
+ NamingServer srv = new NamingServer();
+ context = new NamingContext(nameSpaces.getGlobalContext().getEnvironment(), null, srv);
+ }
+
+ @Override
+ public void stop() throws Exception
+ {
+ context = null;
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEComponent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEModule.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEModule.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/main/java/org/jboss/reloaded/naming/deployers/mc/MCJavaEEModule.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -22,6 +22,7 @@
package org.jboss.reloaded.naming.deployers.mc;
import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
import org.jboss.reloaded.naming.spi.JavaEEApplication;
import org.jboss.reloaded.naming.spi.JavaEEModule;
@@ -52,15 +53,14 @@
public void start() throws Exception
{
parentContext = (application != null ? application.getContext() : nameSpaces.getGlobalContext());
- log.info("name = " + name + ", parentContext = " + parentContext);
- // TODO: full path of the module
- context = parentContext.createSubcontext(name);
+ context = Util.createSubcontext(parentContext, name);
+ log.debug("Installed context " + context + " for JavaEE module " + name + ", parentContext = " + parentContext);
}
@Override
public void stop() throws Exception
{
- parentContext.unbind(name);
+ Util.unbind(parentContext, name);
context = null;
parentContext = null;
}
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesDeployer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesDeployer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesDeployer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeploymentVisitor;
+
+import java.util.List;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummiesDeployer extends AbstractComponentDeployer<DummiesMetaData, DummyMetaData>
+{
+ public DummiesDeployer()
+ {
+ setDeploymentVisitor(new DummiesDeploymentVisitor());
+// setComponentVisitor(new DummyComponentVisitor());
+ setOutput(DummyMetaData.class);
+ }
+
+ private class DummiesDeploymentVisitor extends AbstractDeploymentVisitor<DummyMetaData, DummiesMetaData>
+ {
+ @Override
+ protected List<? extends DummyMetaData> getComponents(DummiesMetaData deployment)
+ {
+ return deployment;
+ }
+
+ @Override
+ protected Class<DummyMetaData> getComponentType()
+ {
+ return DummyMetaData.class;
+ }
+
+ public Class<DummiesMetaData> getVisitorType()
+ {
+ return DummiesMetaData.class;
+ }
+
+ @Override
+ protected String getComponentName(DummyMetaData attachment)
+ {
+ return attachment.getName();
+ }
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesMetaData.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesMetaData.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesMetaData.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummiesMetaData extends ArrayList<DummyMetaData>
+{
+ public static DummiesMetaData create(String... names)
+ {
+ DummiesMetaData md = new DummiesMetaData();
+ for(String s : names)
+ {
+ md.add(new DummyMetaData(s));
+ }
+ return md;
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummiesMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEApplicationInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEApplicationInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEApplicationInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEApplicationInformer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummyJavaEEApplicationInformer implements JavaEEApplicationInformer
+{
+ private static final String REQUIRED_ATTACHMENTS[] = { JBossAppMetaData.class.getName() };
+
+ public String getApplicationName(DeploymentUnit deploymentUnit) throws IllegalArgumentException
+ {
+ if(!isJavaEEApplication(deploymentUnit))
+ return null;
+
+ String name = deploymentUnit.getSimpleName();
+ return name.substring(0, name.length() - 4);
+ }
+
+ public boolean isJavaEEApplication(DeploymentUnit deploymentUnit)
+ {
+ return deploymentUnit.isAttachmentPresent(JBossAppMetaData.class);
+ }
+
+ public String[] getRequiredAttachments()
+ {
+ return REQUIRED_ATTACHMENTS;
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEApplicationInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEComponentInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEComponentInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEComponentInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummyJavaEEComponentInformer extends DummyJavaEEModuleInformer implements JavaEEComponentInformer
+{
+ private static final String[] REQUIRED_ATTACHMENTS = { DummyMetaData.class.getName() };
+
+ public String getComponentName(DeploymentUnit unit)
+ {
+ return unit.getAttachment(DummyMetaData.class).getName();
+ }
+
+ @Override
+ public String[] getRequiredAttachments()
+ {
+ return REQUIRED_ATTACHMENTS;
+ }
+
+ public boolean isJavaEEComponent(DeploymentUnit unit)
+ {
+ return unit.isAttachmentPresent(DummyMetaData.class);
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEComponentInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEModuleInformer.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEModuleInformer.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEModuleInformer.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEModuleInformer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummyJavaEEModuleInformer extends DummyJavaEEApplicationInformer implements JavaEEModuleInformer
+{
+ public String getApplicationName(DeploymentUnit deploymentUnit)
+ {
+ DeploymentUnit topLevel = deploymentUnit.getTopLevel();
+ return super.getApplicationName(topLevel);
+ }
+
+ public String getModulePath(DeploymentUnit deploymentUnit)
+ {
+ String path = deploymentUnit.getRelativePath();
+ if(path == null || path.length() == 0)
+ path = deploymentUnit.getSimpleName();
+ return path.substring(0, path.length() - 4);
+ }
+
+ public ModuleType getModuleType(DeploymentUnit deploymentUnit)
+ {
+ if(deploymentUnit.getSimpleName().endsWith(".jar"))
+ return ModuleType.JAVA;
+ return null;
+ }
+
+ public String[] getRequiredAttachments()
+ {
+ return super.getRequiredAttachments();
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyJavaEEModuleInformer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyMetaData.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyMetaData.java (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyMetaData.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.deployers.test.common;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class DummyMetaData
+{
+ private String name;
+
+ public DummyMetaData(String s)
+ {
+ this.name = s;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/common/DummyMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/simple/SimpleTestCase.java
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/simple/SimpleTestCase.java 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/test/java/org/jboss/reloaded/naming/deployers/test/simple/SimpleTestCase.java 2010-01-05 17:54:41 UTC (rev 99035)
@@ -26,6 +26,9 @@
import org.jboss.dependency.spi.ControllerMode;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
import org.jboss.deployers.vfs.plugins.client.AbstractVFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.kernel.Kernel;
@@ -33,15 +36,21 @@
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.reloaded.naming.deployers.test.common.DummiesMetaData;
import org.jboss.reloaded.naming.service.NameSpaces;
import org.jboss.virtual.AssembledDirectory;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
import java.net.URL;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
/**
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
@@ -50,14 +59,41 @@
{
private static Kernel kernel;
private static BasicXMLDeployer deployer;
+ private static MainDeployer mainDeployer;
+ private static InitialContext ctx;
+ protected static final void assertNameNotFound(String name) throws NamingException
+ {
+ try
+ {
+ ctx.lookup(name);
+ fail("Expected NameNotFoundException for " + name);
+ }
+ catch(NameNotFoundException e)
+ {
+ // good
+ }
+ }
+
@BeforeClass
- public static void beforeClass()
+ public static void beforeClass() throws Exception
{
AbstractBootstrap bootstrap = new BasicBootstrap();
bootstrap.run();
kernel = bootstrap.getKernel();
deployer = new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
+
+ deploy(SimpleTestCase.class.getClassLoader(), "classloader.xml");
+ deploy(SimpleTestCase.class.getClassLoader(), "deployers.xml");
+
+ mainDeployer = getBean("MainDeployer", ControllerState.INSTALLED, MainDeployer.class);
+
+ deploy(SimpleTestCase.class.getClassLoader(), "jndi-beans.xml");
+ deploy(SimpleTestCase.class.getClassLoader(), "reloaded-naming-deployers-beans.xml");
+
+ deploy(SimpleTestCase.class.getClassLoader(), "dummy-deployers-beans.xml");
+
+ ctx = new InitialContext();
}
protected static <T> T getBean(String name, ControllerState state, Class<T> expectedType)
@@ -100,35 +136,90 @@
@Test
public void test1() throws Exception
{
- deploy(getClass().getClassLoader(), "classloader.xml");
- deploy(getClass().getClassLoader(), "deployers.xml");
+ AssembledDirectory root1 = AssembledDirectory.createAssembledDirectory("test1", "test1.ear");
+ VFSDeployment deployment1 = new AbstractVFSDeployment(root1);
+ ((MutableAttachments) deployment1.getPredeterminedManagedObjects()).addAttachment(JBossAppMetaData.class, new JBossAppMetaData());
+ mainDeployer.deploy(deployment1);
- MainDeployer mainDeployer = getBean("MainDeployer", ControllerState.INSTALLED, MainDeployer.class);
+ AssembledDirectory root2 = AssembledDirectory.createAssembledDirectory("test2", "test2.ear");
+ AssembledDirectory moduleA = root2.mkdir("moduleA.jar");
+ VFSDeployment deployment2 = new AbstractVFSDeployment(root2);
+ ((MutableAttachments) deployment2.getPredeterminedManagedObjects()).addAttachment(JBossAppMetaData.class, new JBossAppMetaData());
+ mainDeployer.deploy(deployment2);
- deploy(getClass().getClassLoader(), "jndi-beans.xml");
- deploy(getClass().getClassLoader(), "reloaded-naming-deployers-beans.xml");
+ InitialContext ctx = new InitialContext();
+ NameSpaces nameSpaces = getBean("NameSpaces", ControllerState.INSTALLED, NameSpaces.class);
+ assertNotNull(nameSpaces.getGlobalContext());
+ // basically the lookup is what really checks the functionality, not null is a bonus
+ assertNotNull(ctx.lookup("java:global"));
+ assertNotNull(ctx.lookup("java:global/test1"));
+ assertNotNull(ctx.lookup("java:global/test2"));
+ assertNotNull(ctx.lookup("java:global/test2/moduleA"));
- {
- AssembledDirectory root = AssembledDirectory.createAssembledDirectory("test1", "test1.ear");
- VFSDeployment deployment = new AbstractVFSDeployment(root);
- mainDeployer.deploy(deployment);
- }
- {
- AssembledDirectory root = AssembledDirectory.createAssembledDirectory("test2", "test2.ear");
- AssembledDirectory moduleA = root.mkdir("moduleA.jar");
- VFSDeployment deployment = new AbstractVFSDeployment(root);
- mainDeployer.deploy(deployment);
- }
+ mainDeployer.undeploy(deployment1);
+ mainDeployer.undeploy(deployment2);
- InitialContext ctx = new InitialContext();
- NameSpaces nameSpaces = getBean("NameSpaces", ControllerState.INSTALLED, NameSpaces.class);
- System.out.println(nameSpaces.getGlobalContext());
- System.out.println(ctx.lookup("java:global"));
- System.out.println(ctx.lookup("java:global/test1"));
- System.out.println(ctx.lookup("java:global/test2"));
- System.out.println(ctx.lookup("java:global/test2/moduleA"));
+ assertNameNotFound("java:global/test1");
+ assertNameNotFound("java:global/test2");
}
+ @Test
+ @Ignore
+ public void testComponents() throws Exception
+ {
+ AssembledDirectory root = AssembledDirectory.createAssembledDirectory("components", "components.jar");
+ VFSDeployment deployment = new AbstractVFSDeployment(root);
+ ((MutableAttachments) deployment.getPredeterminedManagedObjects()).addAttachment(DummiesMetaData.class, DummiesMetaData.create("A", "B"));
+ mainDeployer.deploy(deployment);
+
+ // basically the lookup is what really checks the functionality, not null is a bonus
+ assertNotNull(ctx.lookup("java:global"));
+ assertNotNull(ctx.lookup("java:global/components"));
+
+ mainDeployer.undeploy(deployment);
+
+ assertNameNotFound("java:global/components");
+ }
+
+ @Test
+ public void testPath() throws Exception
+ {
+ AssembledDirectory root = AssembledDirectory.createAssembledDirectory("testPath", "testPath.ear");
+ AssembledDirectory path = root.mkdir("path");
+ AssembledDirectory moduleA = path.mkdir("modulePath.jar");
+ VFSDeployment deployment = new AbstractVFSDeployment(root);
+ // so we don't need an EAR structure deployer
+ StructureMetaData smd = StructureMetaDataFactory.createStructureMetaData();
+ smd.addContext(StructureMetaDataFactory.createContextInfo("path/modulePath.jar"));
+ ((MutableAttachments) deployment.getPredeterminedManagedObjects()).addAttachment(StructureMetaData.class, smd);
+ ((MutableAttachments) deployment.getPredeterminedManagedObjects()).addAttachment(JBossAppMetaData.class, new JBossAppMetaData());
+ mainDeployer.deploy(deployment);
+
+ // basically the lookup is what really checks the functionality, not null is a bonus
+ assertNotNull(ctx.lookup("java:global"));
+ assertNotNull(ctx.lookup("java:global/testPath/path/modulePath"));
+
+ mainDeployer.undeploy(deployment);
+
+ assertNameNotFound("java:global/testPath/path/modulePath");
+ }
+
+ @Test
+ public void testStandaloneModule() throws Exception
+ {
+ AssembledDirectory root = AssembledDirectory.createAssembledDirectory("standalone", "standalone.jar");
+ VFSDeployment deployment = new AbstractVFSDeployment(root);
+ mainDeployer.deploy(deployment);
+
+ // basically the lookup is what really checks the functionality, not null is a bonus
+ assertNotNull(ctx.lookup("java:global"));
+ assertNotNull(ctx.lookup("java:global/standalone"));
+
+ mainDeployer.undeploy(deployment);
+
+ assertNameNotFound("java:global/standalone");
+ }
+
protected static void validate() throws Exception
{
try
Added: projects/reloaded/trunk/naming-deployers/src/test/resources/dummy-deployers-beans.xml
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/resources/dummy-deployers-beans.xml (rev 0)
+++ projects/reloaded/trunk/naming-deployers/src/test/resources/dummy-deployers-beans.xml 2010-01-05 17:54:41 UTC (rev 99035)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="DummiesDeployer" class="org.jboss.reloaded.naming.deployers.test.common.DummiesDeployer"/>
+</deployment>
\ No newline at end of file
Property changes on: projects/reloaded/trunk/naming-deployers/src/test/resources/dummy-deployers-beans.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: projects/reloaded/trunk/naming-deployers/src/test/resources/reloaded-naming-deployers-beans.xml
===================================================================
--- projects/reloaded/trunk/naming-deployers/src/test/resources/reloaded-naming-deployers-beans.xml 2010-01-05 17:41:47 UTC (rev 99034)
+++ projects/reloaded/trunk/naming-deployers/src/test/resources/reloaded-naming-deployers-beans.xml 2010-01-05 17:54:41 UTC (rev 99035)
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="AppNamingDeployer" class="org.jboss.reloaded.naming.deployers.AppNamingDeployer"/>
- <bean name="ModuleNamingDeployer" class="org.jboss.reloaded.naming.deployers.ModuleNamingDeployer"/>
+ <bean name="JavaEEApplicationInformer" class="org.jboss.reloaded.naming.deployers.test.common.DummyJavaEEApplicationInformer"/>
+ <bean name="JavaEEModuleInformer" class="org.jboss.reloaded.naming.deployers.test.common.DummyJavaEEModuleInformer"/>
+ <bean name="JavaEEComponentInformer" class="org.jboss.reloaded.naming.deployers.test.common.DummyJavaEEComponentInformer"/>
+
+ <bean name="AppNamingDeployer" class="org.jboss.reloaded.naming.deployers.AppNamingDeployer">
+ <constructor><parameter><inject bean="JavaEEApplicationInformer"/></parameter></constructor>
+ </bean>
+ <bean name="ModuleNamingDeployer" class="org.jboss.reloaded.naming.deployers.ModuleNamingDeployer">
+ <constructor><parameter><inject bean="JavaEEModuleInformer"/></parameter></constructor>
+ </bean>
+ <bean name="ComponentNamingDeployer" class="org.jboss.reloaded.naming.deployers.ComponentNamingDeployer">
+ <constructor><parameter><inject bean="JavaEEComponentInformer"/></parameter></constructor>
+ </bean>
</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list