Author: pete.muir(a)jboss.org
Date: 2009-03-15 14:44:17 -0400 (Sun, 15 Mar 2009)
New Revision: 2009
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/NoNamingContext.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/Reflections.java
extensions/trunk/se/src/main/resources/log4j.xml
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/
Removed:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/ParametersBinding.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bootstrap/
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/exception/
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/lifecycle/
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/DefaultResourceLoader.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/EnumerationEnumeration.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/lifecycle/
extensions/trunk/se/src/main/resources/log4j.properties
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/
Modified:
extensions/trunk/se/
extensions/trunk/se/pom.xml
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/URLScanner.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
Log:
Start to fix up SE for new bootstrap
Property changes on: extensions/trunk/se
___________________________________________________________________
Name: svn:ignore
- nbactions.xml
target
+ nbactions.xml
target
.classpath
.project
.settings
Modified: extensions/trunk/se/pom.xml
===================================================================
--- extensions/trunk/se/pom.xml 2009-03-15 18:17:47 UTC (rev 2008)
+++ extensions/trunk/se/pom.xml 2009-03-15 18:44:17 UTC (rev 2009)
@@ -22,79 +22,21 @@
<target>1.5</target>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jalopy-maven-plugin</artifactId>
- <version>1.0-alpha-1</version>
- <!-- This wipes out UNDO in IDEs. Run manually instead.
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>format</goal>
- </goals>
- </execution>
- </executions>
- -->
- </plugin>
- <plugin>
- <groupId>com.google.code.maven-license-plugin</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <version>1.4.0</version>
- <configuration>
- <basedir>${basedir}</basedir>
- <header>${basedir}/src/etc/header.txt</header>
- <quiet>false</quiet>
- <failIfMissing>true</failIfMissing>
- <aggregate>false</aggregate>
- <encoding>UTF-8</encoding>
- </configuration>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>format</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <
url>http://repository.jboss.org/maven2</url>
- <releases>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshots Repository</name>
- <
url>http://snapshots.jboss.org/maven2</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- </repository>
- <repository>
- <id>repository.codehaus.org</id>
- <name>Codehaus Repository</name>
- <url>http://repository.codehaus.org</url>
- </repository>
- </repositories>
+
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
<scope>test</scope>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -120,16 +62,7 @@
</exclusion>
</exclusions>
</dependency>
- <!-- TODO: these have to go or be replaced with mocks -->
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
+
</dependencies>
</project>
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -17,11 +17,22 @@
package org.jboss.webbeans.environment.se;
import javax.event.Observes;
-import org.jboss.webbeans.environment.se.boot.WebBeansBootstrap;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environments;
+import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
+import org.jboss.webbeans.environment.se.beans.ParametersFactory;
+import org.jboss.webbeans.environment.se.discovery.WebBeanDiscoveryImpl;
import org.jboss.webbeans.environment.se.events.Shutdown;
-import org.jboss.webbeans.environment.se.events.ShutdownRequest;
+import org.jboss.webbeans.environment.se.resources.NoNamingContext;
+import org.jboss.webbeans.environment.se.util.Reflections;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.resources.spi.NamingContext;
/**
* This is the main class that should always be called from the command
@@ -30,11 +41,15 @@
* java -jar MyApp.jar org.jboss.webbeans.environment.se.StarMain arguments
* </code>
* @author Peter Royle
+ * @author Pete Muir
*/
public class StartMain
{
- private WebBeansBootstrap webBeansBootstrap;
+ private static final String BOOTSTRAP_IMPL_CLASS_NAME =
"org.jboss.webbeans.bootstrap.WebBeansBootstrap";
+
+ private final Bootstrap bootstrap;
+ private final BeanStore applicationBeanStore;
private String[] args;
private boolean hasShutdownBeenCalled = false;
Log log = Logging.getLog( StartMain.class );
@@ -42,16 +57,27 @@
public StartMain( String[] commandLineArgs )
{
this.args = commandLineArgs;
+ try
+ {
+ bootstrap = Reflections.newInstance(BOOTSTRAP_IMPL_CLASS_NAME,
Bootstrap.class);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error loading Web Beans bootstrap,
check that Web Beans is on the classpath", e);
+ }
+ this.applicationBeanStore = new ConcurrentHashMapBeanStore();
}
private void go()
- {
- webBeansBootstrap = new WebBeansBootstrap( args );
-
- webBeansBootstrap.initialize();
-
- webBeansBootstrap.boot();
-
+ {
+ bootstrap.setEnvironment(Environments.SE);
+ bootstrap.getServices().add(WebBeanDiscovery.class, new WebBeanDiscoveryImpl());
+ bootstrap.getServices().add(NamingContext.class, new NoNamingContext());
+ bootstrap.setApplicationContext(applicationBeanStore);
+ bootstrap.initialize();
+ bootstrap.boot();
+ bootstrap.getManager().getInstanceByType(ParametersFactory.class).setArgs(args);
+ DependentContext.INSTANCE.setActive(true);
}
/**
@@ -69,7 +95,7 @@
* Shutdown event.
* @param shutdownRequest
*/
- public void shutdown( @Observes ShutdownRequest shutdownRequest )
+ public void shutdown( @Observes @Shutdown Manager shutdownRequest )
{
synchronized (this)
{
@@ -77,7 +103,7 @@
if (!hasShutdownBeenCalled)
{
hasShutdownBeenCalled = true;
- webBeansBootstrap.shutdown();
+ bootstrap.shutdown();
} else
{
log.debug( "Skipping spurious call to shutdown");
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -16,14 +16,16 @@
*/
package org.jboss.webbeans.environment.se.beans;
-import org.jboss.webbeans.environment.se.bindings.Parameters;
-
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import javax.context.ApplicationScoped;
import javax.inject.Produces;
+import org.jboss.webbeans.environment.se.bindings.Parameters;
+
/**
* The simple bean that will hold the command line arguments
* and make them available by injection (using the @Parameters binding).
@@ -42,10 +44,10 @@
*/
@Produces
@Parameters
- public ArrayList<String> getArgs( )
+ // TODO Give generic type - WBRI-186
+ public List getArgs( )
{
- // TODO (PR): is there an unmodifiable, serializable List?
- return new ArrayList( Arrays.asList( this.args ) );
+ return Collections.unmodifiableList(new ArrayList<String>( Arrays.asList(
this.args ) ));
}
/**
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/ParametersBinding.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/ParametersBinding.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/ParametersBinding.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,29 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.se.bindings;
-
-import javax.inject.AnnotationLiteral;
-
-/**
- *
- * @author Peter Royle
- */
-public class ParametersBinding
- extends AnnotationLiteral<Parameters>
- implements Parameters
-{
-}
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/URLScanner.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/URLScanner.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/URLScanner.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -16,9 +16,6 @@
*/
package org.jboss.webbeans.environment.se.deployment;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -31,6 +28,9 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
/**
* Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
*
@@ -50,7 +50,6 @@
super( deploymentHandlers, classLoader );
}
- @Override
public void scanDirectories( File[] directories )
{
for ( File directory : directories )
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,4 +1,4 @@
-/**
+/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -16,15 +16,25 @@
*/
package org.jboss.webbeans.environment.se.events;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
/**
* Fired by webbeans SE before shutting down. Applications and modules should
* release resources cleanly in response to this event.
* @author Peter Royle
*/
-public class Shutdown
+@BindingType
+@Retention( RetentionPolicy.RUNTIME )
+@Target( {ElementType.PARAMETER,
+ ElementType.METHOD,
+ ElementType.FIELD
+} )
+public @interface Shutdown
{
- public Shutdown()
- {
- }
}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,30 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.se.events;
-
-/**
-* Should be fired by application to trigger shutting down of the WebBEans SE
- * manager. This will in turn fire the Shutdown
- * @author Peter Royle
- */
-public class ShutdownRequest
-{
-
- public ShutdownRequest()
- {
- }
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/DefaultResourceLoader.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/DefaultResourceLoader.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/DefaultResourceLoader.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.se.resources;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceLoadingException;
-import org.jboss.webbeans.util.EnumerationIterable;
-
-/**
- * A simple resource loader.
- *
- * Uses {@link DefaultResourceLoader}'s classloader if the Thread Context
- * Classloader isn't available
- *
- * @author Pete Muir
- *
- */
-public class DefaultResourceLoader implements ResourceLoader
-{
-
- public Class<?> classForName(String name)
- {
-
- try
- {
- if (Thread.currentThread().getContextClassLoader() != null)
- {
- return Thread.currentThread().getContextClassLoader().loadClass(name);
- }
- else
- {
- return Class.forName(name);
- }
- }
- catch (ClassNotFoundException e)
- {
- throw new ResourceLoadingException(e);
- }
- catch (NoClassDefFoundError e)
- {
- throw new ResourceLoadingException(e);
- }
- }
-
- public URL getResource(String name)
- {
- if (Thread.currentThread().getContextClassLoader() != null)
- {
- return Thread.currentThread().getContextClassLoader().getResource(name);
- }
- else
- {
- return getClass().getResource(name);
- }
- }
-
- public Iterable<URL> getResources(String name)
- {
- try
- {
- if (Thread.currentThread().getContextClassLoader() != null)
- {
- return new
EnumerationIterable<URL>(Thread.currentThread().getContextClassLoader().getResources(name));
- }
- else
- {
- return new
EnumerationIterable<URL>(getClass().getClassLoader().getResources(name));
- }
- }
- catch (IOException e)
- {
- throw new ResourceLoadingException(e);
- }
- }
-
-}
Copied:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/NoNamingContext.java
(from rev 2007,
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/UnsupportedNaming.java)
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/NoNamingContext.java
(rev 0)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/resources/NoNamingContext.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -0,0 +1,41 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.se.resources;
+
+import org.jboss.webbeans.resources.spi.NamingContext;
+
+/**
+ *
+ * @author Peter Royle
+ */
+public class NoNamingContext
+ implements NamingContext
+{
+
+ public NoNamingContext() {}
+
+ public void bind( String name, Object value )
+ {
+ // No-op
+ }
+
+ public <T> T lookup( String name, Class<? extends T> expectedType )
+ {
+ return null;
+ }
+
+}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/EnumerationEnumeration.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/EnumerationEnumeration.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/EnumerationEnumeration.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,85 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.se.util;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-public class EnumerationEnumeration<T>
- implements Enumeration<T>
-{
- private Enumeration<T>[] enumerations;
- private int loc = 0;
-
- public EnumerationEnumeration( Enumeration<T>[] enumerations )
- {
- this.enumerations = enumerations;
- }
-
- public boolean hasMoreElements( )
- {
- for ( int i = loc; i < enumerations.length; i++ )
- {
- if ( enumerations[i].hasMoreElements( ) )
- {
- return true;
- }
- }
-
- return false;
- }
-
- public T nextElement( )
- {
- while ( isCurrentEnumerationAvailable( ) )
- {
- if ( currentHasMoreElements( ) )
- {
- return currentNextElement( );
- } else
- {
- nextEnumeration( );
- }
- }
-
- throw new NoSuchElementException( );
- }
-
- private void nextEnumeration( )
- {
- loc++;
- }
-
- /*private boolean isNextEnumerationAvailable()
- {
- return loc < enumerations.length-1;
- }*/
- private boolean isCurrentEnumerationAvailable( )
- {
- return loc < enumerations.length;
- }
-
- private T currentNextElement( )
- {
- return enumerations[loc].nextElement( );
- }
-
- private boolean currentHasMoreElements( )
- {
- return enumerations[loc].hasMoreElements( );
- }
-}
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/Reflections.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/Reflections.java
(rev 0)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/Reflections.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -0,0 +1,47 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.se.util;
+
+/**
+ * Reflection utilities
+ *
+ * @author Pete Muir
+ *
+ */
+public class Reflections
+{
+
+ private Reflections(String name) {}
+
+ public static <T> T newInstance(String className, Class<T> expectedType)
throws InstantiationException, IllegalAccessException, ClassNotFoundException
+ {
+ return loadClass(className, expectedType).newInstance();
+ }
+
+ public static <T> Class<? extends T> loadClass(String className,
Class<T> expectedType) throws ClassNotFoundException
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return
Thread.currentThread().getContextClassLoader().loadClass(className).asSubclass(expectedType);
+ }
+ else
+ {
+ return Class.forName(className).asSubclass(expectedType);
+ }
+ }
+
+}
Property changes on:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/Reflections.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: extensions/trunk/se/src/main/resources/log4j.properties
===================================================================
--- extensions/trunk/se/src/main/resources/log4j.properties 2009-03-15 18:17:47 UTC (rev
2008)
+++ extensions/trunk/se/src/main/resources/log4j.properties 2009-03-15 18:44:17 UTC (rev
2009)
@@ -1,25 +0,0 @@
-#
-# JBoss, Home of Professional Open Source
-# Copyright 2008, Red Hat Middleware LLC, and individual contributors
-# by the @authors tag. See the copyright.txt in the distribution for a
-# full listing of individual contributors.
-#
-# Licensed 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.
-#
-# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=DEBUG, A1
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Added: extensions/trunk/se/src/main/resources/log4j.xml
===================================================================
--- extensions/trunk/se/src/main/resources/log4j.xml (rev 0)
+++ extensions/trunk/se/src/main/resources/log4j.xml 2009-03-15 18:44:17 UTC (rev 2009)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
+
+ <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{2}] %m%n"/>
+ </layout>
+ <filter class="org.apache.log4j.varia.StringMatchFilter">
+ <param name="AcceptOnMatch" value="false" />
+ <param name="StringToMatch" value="Failure while notifying an
observer of event [a]" />
+ </filter>
+ </appender>
+
+ <!-- ############### Web Beans logging ################### -->
+
+ <category name="org.jboss.webbeans">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: extensions/trunk/se/src/main/resources/log4j.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -1,75 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.se;
-
-import javax.inject.manager.Manager;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.environment.se.beans.MainTestBean;
-import org.jboss.webbeans.environment.se.beans.ParametersTestBean;
-import org.jboss.webbeans.environment.se.events.ShutdownRequest;
-
-/**
- *
- * @author Peter Royle
- */
-public class StartMainTest extends TestCase {
-
- public static String[] ARGS = new String[] { "arg1", "arg2",
"arg 3"};
-
- public StartMainTest(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test of main method, of class StartMain. Checks that the beans
- * found in the org.jboss.webbeans.environment.se.beans package are
- * initialised as expected.
- */
- public void testMain()
- {
- String[] args = ARGS ;
- StartMain.main( args );
-
- Manager manager = CurrentManager.rootManager();
- MainTestBean mainTestBean = manager.getInstanceByType( MainTestBean.class );
- Assert.assertNotNull( mainTestBean );
-
- ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
- Assert.assertNotNull( paramsBean );
- Assert.assertNotNull( paramsBean.getParam1() );
- Assert.assertEquals( ARGS[0], paramsBean.getParam1() );
- Assert.assertNotNull( paramsBean.getParam2() );
- Assert.assertEquals( ARGS[1], paramsBean.getParam2() );
- Assert.assertNotNull( paramsBean.getParam3() );
- Assert.assertEquals( ARGS[2], paramsBean.getParam3() );
-
- manager.fireEvent( new ShutdownRequest() );
- }
-
-}
Copied:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
(from rev 2007,
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java)
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
(rev 0)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -0,0 +1,66 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.se.test;
+
+import javax.inject.AnnotationLiteral;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.environment.se.StartMain;
+import org.jboss.webbeans.environment.se.events.Shutdown;
+import org.jboss.webbeans.environment.se.test.beans.MainTestBean;
+import org.jboss.webbeans.environment.se.test.beans.ParametersTestBean;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Peter Royle
+ */
+public class StartMainTest {
+
+ public static String[] ARGS = new String[] { "arg1", "arg2",
"arg 3"};
+
+
+ /**
+ * Test of main method, of class StartMain. Checks that the beans
+ * found in the org.jboss.webbeans.environment.se.beans package are
+ * initialised as expected.
+ */
+ @Test
+ public void testMain()
+ {
+ String[] args = ARGS ;
+ StartMain.main( args );
+
+ Manager manager = CurrentManager.rootManager();
+ MainTestBean mainTestBean = manager.getInstanceByType( MainTestBean.class );
+ Assert.assertNotNull( mainTestBean );
+
+ ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
+ Assert.assertNotNull( paramsBean );
+ Assert.assertNotNull( paramsBean.getParam1() );
+ Assert.assertEquals( ARGS[0], paramsBean.getParam1() );
+ Assert.assertNotNull( paramsBean.getParam2() );
+ Assert.assertEquals( ARGS[1], paramsBean.getParam2() );
+ Assert.assertNotNull( paramsBean.getParam3() );
+ Assert.assertEquals( ARGS[2], paramsBean.getParam3() );
+
+ manager.fireEvent( manager, new AnnotationLiteral<Shutdown>() {} );
+ }
+
+}
Copied: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans
(from rev 2007,
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans)
Modified:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/MainTestBean.java 2009-03-15
17:44:31 UTC (rev 2007)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.se.beans;
+package org.jboss.webbeans.environment.se.test.beans;
import javax.inject.Current;
import javax.inject.Initializer;
Modified:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/ParametersTestBean.java 2009-03-15
17:44:31 UTC (rev 2007)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -16,13 +16,15 @@
*/
-package org.jboss.webbeans.environment.se.beans;
+package org.jboss.webbeans.environment.se.test.beans;
import java.util.List;
+
import javax.inject.Initializer;
-import junit.framework.Assert;
-import org.jboss.webbeans.environment.se.StartMainTest;
+
import org.jboss.webbeans.environment.se.bindings.Parameters;
+import org.jboss.webbeans.environment.se.test.StartMainTest;
+import org.testng.Assert;
/**
*
@@ -37,7 +39,7 @@
@Initializer
public void init(@Parameters List<String> params) {
Assert.assertNotNull( params );
- Assert.assertEquals( "Unexpected number of arguments",
StartMainTest.ARGS.length, params.size() );
+ Assert.assertEquals( StartMainTest.ARGS.length, params.size(), "Unexpected
number of arguments");
param1 = params.get( 0 );
param2 = params.get( 1 );
param3 = params.get( 2 );
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-15
18:17:47 UTC (rev 2008)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-15
18:44:17 UTC (rev 2009)
@@ -26,6 +26,7 @@
import org.jboss.webbeans.bean.standard.InjectionPointBean;
import org.jboss.webbeans.bean.standard.ManagerBean;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.bootstrap.api.helpers.AbstractBootstrap;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.ApplicationContext;
@@ -106,11 +107,14 @@
beanDeployer.addClasses(classes);
beanDeployer.addBean(ManagerBean.of(manager));
beanDeployer.addBean(InjectionPointBean.of(manager));
- beanDeployer.addClass(ConversationImpl.class);
- beanDeployer.addClass(ServletConversationManager.class);
- beanDeployer.addClass(JavaSEConversationTerminator.class);
- beanDeployer.addClass(NumericConversationIdGenerator.class);
- beanDeployer.addClass(HttpSessionManager.class);
+ if (!getEnvironment().equals(Environments.SE))
+ {
+ beanDeployer.addClass(ConversationImpl.class);
+ beanDeployer.addClass(ServletConversationManager.class);
+ beanDeployer.addClass(JavaSEConversationTerminator.class);
+ beanDeployer.addClass(NumericConversationIdGenerator.class);
+ beanDeployer.addClass(HttpSessionManager.class);
+ }
beanDeployer.deploy();
}