Author: peteroyle
Date: 2009-03-08 17:02:09 -0400 (Sun, 08 Mar 2009)
New Revision: 1818
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/NoopTransactionService.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java
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/
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/MainTestBean.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/ParametersTestBean.java
extensions/trunk/se/src/test/resources/
extensions/trunk/se/src/test/resources/beans.xml
extensions/trunk/se/src/test/resources/log4j.properties
Removed:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/ClassDeploymentMetadata.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentMetadata.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentStrategy.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/StandardDeploymentStrategy.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/WebBeansDeploymentProperties.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Setup.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Start.java
Modified:
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/boot/WebBeansBootstrap.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/AbstractScanner.java
extensions/trunk/se/src/main/resources/log4j.properties
Log:
Added NoOp Transaction Service. Added Test. Added optional ShutdownRequest event.
Modified: extensions/trunk/se/pom.xml
===================================================================
--- extensions/trunk/se/pom.xml 2009-03-08 20:58:51 UTC (rev 1817)
+++ extensions/trunk/se/pom.xml 2009-03-08 21:02:09 UTC (rev 1818)
@@ -100,7 +100,6 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-ri-spi</artifactId>
</dependency>
-
<!-- TODO (PR): remove this dependency -->
<dependency>
<groupId>org.jboss.webbeans</groupId>
@@ -120,10 +119,16 @@
</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-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -16,7 +16,12 @@
*/
package org.jboss.webbeans.environment.se;
+import javax.event.Observes;
import org.jboss.webbeans.environment.se.boot.WebBeansBootstrap;
+import org.jboss.webbeans.environment.se.events.Shutdown;
+import org.jboss.webbeans.environment.se.events.ShutdownRequest;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
/**
* This is the main class that should always be called from the command
@@ -29,23 +34,24 @@
public class StartMain
{
- String[] args;
+ private WebBeansBootstrap webBeansBootstrap;
+ private String[] args;
+ private boolean hasShutdownBeenCalled = false;
+ Log log = Logging.getLog( StartMain.class );
public StartMain( String[] commandLineArgs )
{
this.args = commandLineArgs;
}
- public void go()
+ private void go()
{
- WebBeansBootstrap webBeansBootstrap = new WebBeansBootstrap( args );
+ webBeansBootstrap = new WebBeansBootstrap( args );
webBeansBootstrap.initialize();
webBeansBootstrap.boot();
- webBeansBootstrap.shutdown();
-
}
/**
@@ -57,39 +63,27 @@
{
new StartMain( args ).go();
}
+
/**
- * When an exception happens in your main app, you don't want
- * the manager to come down in a screaming heap. Well, not all the time.
- * Sometimes you just want to exit gently. This method will detect such
- * times and behave appropriately.
- * @param e
+ * The observer of the optional shutdown request which will in turn fire the
+ * Shutdown event.
+ * @param shutdownRequest
*/
-// private void handleException( Throwable e )
-// {
-// // check for a 'special' root cause
-// boolean dealtWith = false;
-// Throwable cause = e.getCause();
-//
-// while (cause != null)
-// {
-// if (cause instanceof CleanShutdownException)
-// {
-// // This is a request to shut down silently, so swollow it.
-// // Hoewver, if there's a message, then print it to stdout
-// if (cause.getMessage() != null)
-// {
-// System.out.println( cause.getMessage() );
-// }
-//
-// dealtWith = true;
-// }
-//
-// cause = cause.getCause();
-// }
-//
-// if (!dealtWith)
-// {
-// e.printStackTrace();
-// }
-// }
+ public void shutdown( @Observes ShutdownRequest shutdownRequest )
+ {
+ synchronized (this)
+ {
+
+ if (!hasShutdownBeenCalled)
+ {
+ hasShutdownBeenCalled = true;
+ webBeansBootstrap.shutdown();
+ } else
+ {
+ log.debug( "Skipping spurious call to shutdown");
+ log.trace( Thread.currentThread().getStackTrace() );
+ }
+ }
+ }
+
}
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/NoopTransactionService.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/NoopTransactionService.java
(rev 0)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/NoopTransactionService.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -0,0 +1,28 @@
+/**
+ * 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.boot;
+
+import org.omg.IOP.TransactionService;
+
+/**
+ *
+ * @author Peter Royle
+ */
+public class NoopTransactionService implements TransactionService {
+
+}
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/WebBeansBootstrap.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/WebBeansBootstrap.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/boot/WebBeansBootstrap.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -18,7 +18,6 @@
import java.lang.annotation.Annotation;
import java.util.List;
-import javax.inject.manager.Manager;
import javax.transaction.Transaction;
import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
@@ -38,6 +37,7 @@
import org.jboss.webbeans.literal.InitializedLiteral;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.manager.api.WebBeansManager;
/**
* Bootstrap class for for WebBeans in SE environment. Provides no JNDI binding.
@@ -80,14 +80,14 @@
{
throw new IllegalStateException( "EjbResolver is not set" );
}
- this.manager = new ManagerImpl( getNamingContext(), getEjbResolver(),
getResourceLoader() );
+ this.manager = new ManagerImpl( getNamingContext(), getEjbResolver(),
getResourceLoader(), getTransactionServices() );
CurrentManager.setRootManager( manager );
lifecycle.initialize();
}
@Override
- public Manager getManager()
+ public WebBeansManager getManager()
{
return manager;
}
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/AbstractScanner.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/AbstractScanner.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/AbstractScanner.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -41,6 +41,7 @@
{
private static class Handler
{
+ public static final String BEANS_XML = "beans.xml";
private ClassDescriptor classDescriptor;
private Set<FileDescriptor> fileDescriptors;
private Set<DeploymentHandler> deploymentHandlers;
@@ -81,7 +82,7 @@
}
} else
{
- if ( name.equals ("beans.xml" ) )
+ if ( name.equals (BEANS_XML) )
{
deploymentHandler.getResources( ).addAll( getAllFileDescriptors( )
);
handled = true;
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/ClassDeploymentMetadata.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/ClassDeploymentMetadata.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/ClassDeploymentMetadata.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,26 +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.deployment;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-public interface ClassDeploymentMetadata
- extends DeploymentMetadata
-{
-
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentMetadata.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentMetadata.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentMetadata.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,32 +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.deployment;
-
-
-/**
- * Metadata about resources the deployment handler is interested in
- *
- * @author pmuir
- *
- */
-public interface DeploymentMetadata
-{
- /**
- * A file name suffixes that this deployment handler is interested in
- */
- public String getFileNameSuffix( );
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentStrategy.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentStrategy.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/DeploymentStrategy.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,180 +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.deployment;
-
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A {@link DeploymentStrategy} coordinates the deployment of resources for a
- * Web Beans SE application.
- *
- * @author Pete Muir
- *
- */
-public abstract class DeploymentStrategy
-{
- private static final LogProvider log = Logging.getLogProvider(
DeploymentStrategy.class );
- private Scanner scanner;
- private List<File> files = new ArrayList<File>( );
- private Set<DeploymentHandler> deploymentHandlers;
-
- /**
- * The key under which to list possible scanners. System properties take
- * precedence over /META-INF/seam-scanner.properties. Entries will be tried
- * in sequential order until a Scanner can be loaded.
- *
- * This can be specified as a System property or in
- * /META-INF/seam-deployment.properties
- */
- public static final String SCANNERS_KEY =
"org.jboss.webbeans.environment.se.deployment.scanners";
-
- /**
- * Do the scan for resources
- *
- * Should only be called by Seam
- *
- */
- public abstract void scan( );
-
- /**
- * Get the scanner being used
- *
- */
- protected Scanner getScanner( )
- {
- if ( scanner == null )
- {
- initScanner( );
- }
-
- return scanner;
- }
-
- /**
- * Get the classloader to use
- */
- public abstract ClassLoader getClassLoader( );
-
- /**
- * Get (or modify) any registered {@link DeploymentHandler}s
- *
- * Implementations of {@link DeploymentStrategy} may add default
- * {@link DeploymentHandler}s
- */
- public Set<DeploymentHandler> getDeploymentHandlers( )
- {
- if ( deploymentHandlers == null )
- {
- initDeploymentHandlers( );
- }
-
- return this.deploymentHandlers;
- }
-
- private void initDeploymentHandlers( )
- {
- this.deploymentHandlers = new HashSet<DeploymentHandler>( );
-
- }
-
- protected void initScanner( )
- {
- List<String> scanners =
- new WebBeansDeploymentProperties( getClassLoader( ) ).getPropertyValues(
SCANNERS_KEY );
-
- for ( String className : scanners )
- {
- Scanner scanner = instantiateScanner( className );
-
- if ( scanner != null )
- {
- log.debug( "Using " + scanner.toString( ) );
- this.scanner = scanner;
-
- return;
- }
- }
-
- log.debug( "Using default URLScanner" );
- ////this.scanner = new URLScanner( this );
- }
-
- private Scanner instantiateScanner( String className )
- {
- try
- {
- Class<Scanner> scannerClass = (Class<Scanner>) getClassLoader(
).loadClass( className );
- Constructor<Scanner> constructor = scannerClass.getConstructor( new
Class[] { DeploymentStrategy.class } );
-
- return constructor.newInstance( new Object[] { this } );
- } catch ( ClassNotFoundException e )
- {
- log.trace( "Unable to use " + className + " as scanner (class
not found)", e );
- } catch ( NoClassDefFoundError e )
- {
- log.trace( "Unable to use " + className + " as scanner
(dependency not found)", e );
- } catch ( ClassCastException e )
- {
- log.trace( "Unable to use " + className +
- " as scanner (class does not implement
org.jboss.seam.deployment.Scanner)" );
- } catch ( InstantiationException e )
- {
- log.trace( "Unable to instantiate scanner " + className, e );
- } catch ( IllegalAccessException e )
- {
- log.trace( "Unable to instantiate scanner " + className, e );
- } catch ( SecurityException e )
- {
- log.trace( className + " must declare public " + className +
- "( ClassLoader classLoader, String ... resourceNames )",
e );
- } catch ( NoSuchMethodException e )
- {
- log.trace( className + " must declare public " + className +
- "( ClassLoader classLoader, String ... resourceNames )",
e );
- } catch ( IllegalArgumentException e )
- {
- log.trace( className + " must declare public " + className +
- "( ClassLoader classLoader, String ... resourceNames )",
e );
- } catch ( InvocationTargetException e )
- {
- log.trace( className + " must declare public " + className +
- "( ClassLoader classLoader, String ... resourceNames )",
e );
- }
-
- return null;
- }
-
- public List<File> getFiles( )
- {
- return files;
- }
-
- public void setFiles( List<File> files )
- {
- this.files = files;
- }
-
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/StandardDeploymentStrategy.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/StandardDeploymentStrategy.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/StandardDeploymentStrategy.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,88 +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.deployment;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * The standard deployment strategy used with Seam, deploys non-hot-deployable
- * Seam components and namespaces
- *
- * @author Pete Muir
- *
- */
-public class StandardDeploymentStrategy
- extends DeploymentStrategy
-{
- private ClassLoader classLoader;
-
- /**
- * The files used to identify a Seam archive
- */
- public static final String[] RESOURCE_NAMES = { "beans.xml" };
-
- private SimpleWebBeansDeploymentHandler simpleWebBeansDeploymentHandler;
- private WebBeansXmlDeploymentHandler webBeansXmlDeploymentHandler;
-
- /**
- * @param classLoader The classloader used to load and handle resources
- */
- public StandardDeploymentStrategy( ClassLoader classLoader )
- {
- this.classLoader = Thread.currentThread( ).getContextClassLoader( );
- simpleWebBeansDeploymentHandler = new SimpleWebBeansDeploymentHandler( );
- getDeploymentHandlers( ).add( simpleWebBeansDeploymentHandler );
- webBeansXmlDeploymentHandler = new WebBeansXmlDeploymentHandler( );
- getDeploymentHandlers( ).add( webBeansXmlDeploymentHandler );
- }
-
- @Override
- public ClassLoader getClassLoader( )
- {
- return classLoader;
- }
-
- /**
- * Get all annotated components known to this strategy
- */
- public Set<ClassDescriptor> getSimpleWebBeans( )
- {
- return Collections.unmodifiableSet( simpleWebBeansDeploymentHandler.getClasses(
) );
- }
-
- /**
- * Get all beans.xml locations
- */
- public Set<FileDescriptor> getWebBeansXMLs( )
- {
- Set<FileDescriptor> fileDescriptors = new HashSet<FileDescriptor>(
);
- fileDescriptors.addAll( webBeansXmlDeploymentHandler.getResources( ) );
-
- return Collections.unmodifiableSet( fileDescriptors );
- }
-
- @Override
- public void scan( )
- {
- getScanner( ).scanResources( RESOURCE_NAMES );
- getScanner( ).scanDirectories( getFiles( ).toArray( new File[0] ) );
- }
-
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/WebBeansDeploymentProperties.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/WebBeansDeploymentProperties.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/deployment/WebBeansDeploymentProperties.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,136 +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.deployment;
-
-import org.jboss.webbeans.environment.se.util.EnumerationEnumeration;
-import static org.jboss.webbeans.util.Strings.split;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-public class WebBeansDeploymentProperties
-{
- private ClassLoader classLoader;
- private Enumeration<URL> urlEnum;
-
- public WebBeansDeploymentProperties( ClassLoader classLoader )
- {
- this.classLoader = classLoader;
- }
-
- /**
- * The resource bundle used to control Seam deployment
- */
- public static final String RESOURCE_BUNDLE =
"META-INF/seam-deployment.properties";
-
- // All resource bundles to use, including legacy names
- private static final String[] RESOURCE_BUNDLES = { RESOURCE_BUNDLE,
"META-INF/seam-scanner.properties" };
-
- /**
- * Get a list of possible values for a given key.
- *
- * First, System properties are tried, followed by the specified resource
- * bundle (first in classpath only).
- *
- * Colon (:) deliminated lists are split out.
- *
- */
- public List<String> getPropertyValues( String key )
- {
- List<String> values = new ArrayList<String>( );
- addPropertiesFromSystem( key, values );
- addPropertiesFromResourceBundle( key, values );
-
- return values;
- }
-
- private void addPropertiesFromSystem( String key, List<String> values )
- {
- addProperty( key,
- System.getProperty( key ),
- values );
- }
-
- private void addPropertiesFromResourceBundle( String key, List<String> values
)
- {
- try
- {
- while ( getResources( ).hasMoreElements( ) )
- {
- URL url = getResources( ).nextElement( );
- Properties properties = new Properties( );
- InputStream propertyStream = url.openStream( );
-
- try
- {
- properties.load( propertyStream );
- addProperty( key,
- properties.getProperty( key ),
- values );
- } finally
- {
- if ( propertyStream != null )
- {
- propertyStream.close( );
- }
- }
- }
- } catch ( IOException e )
- {
- // No - op, file is optional
- }
- }
-
- /*
- * Add the property to the set of properties only if it hasn't already been
added
- */
- private void addProperty( String key, String value, List<String> values )
- {
- if ( value != null )
- {
- String[] properties = split( value, ":" );
-
- for ( String property : properties )
- {
- values.add( property );
- }
- }
- }
-
- private Enumeration<URL> getResources( )
- throws IOException
- {
- if ( urlEnum == null )
- {
- Enumeration<URL>[] enumerations = new
Enumeration[RESOURCE_BUNDLES.length];
-
- for ( int i = 0; i < RESOURCE_BUNDLES.length; i++ )
- {
- enumerations[i] = classLoader.getResources( RESOURCE_BUNDLES[i] );
- }
-
- urlEnum = new EnumerationEnumeration<URL>( enumerations );
- }
-
- return urlEnum;
- }
-}
Deleted:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Setup.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Setup.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Setup.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -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;
-
-
-/**
- * The event which is fired after the manager initialises but before the
- * "Start" event is fired (causing the application to begin).
- * Applications may observe this event in order to perform any additional setup
- * necessary, however it is most useful for setup required to make injection
- * of certain custom beans possible - for example: setting up custom contexts.
- * @author Peter Royle
- */
-public class Setup
-{
-}
Added:
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
(rev 0)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/ShutdownRequest.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -0,0 +1,30 @@
+/**
+ * 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/events/Start.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Start.java 2009-03-08
20:58:51 UTC (rev 1817)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Start.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -1,28 +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;
-
-
-/**
- * The event which is fired after the manager initialises and is ready for the
- * application to start. Applications should provide a method which observes
- * this event as a means of starting the application.
- * @author Peter Royle
- */
-public class Start
-{
-}
Modified: extensions/trunk/se/src/main/resources/log4j.properties
===================================================================
--- extensions/trunk/se/src/main/resources/log4j.properties 2009-03-08 20:58:51 UTC (rev
1817)
+++ extensions/trunk/se/src/main/resources/log4j.properties 2009-03-08 21:02:09 UTC (rev
1818)
@@ -15,7 +15,7 @@
# limitations under the License.
#
# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=TRACE, A1
+log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
Added:
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
(rev 0)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/StartMainTest.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -0,0 +1,75 @@
+/**
+ * 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() );
+ }
+
+}
Added:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/MainTestBean.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/MainTestBean.java
(rev 0)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/MainTestBean.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -0,0 +1,50 @@
+/**
+ * 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.beans;
+
+import javax.inject.Current;
+import javax.inject.Initializer;
+
+/**
+ *
+ * @author Peter Royle
+ */
+public class MainTestBean
+{
+
+ boolean initialised = false;
+ ParametersTestBean parametersTestBean;
+
+ @Initializer
+ public void init(@Current ParametersTestBean paramsTestBean)
+ {
+ this.initialised = true;
+ this.parametersTestBean = paramsTestBean;
+ }
+
+ public ParametersTestBean getParametersTestBean()
+ {
+ return parametersTestBean;
+ }
+
+ public boolean isInitialised()
+ {
+ return initialised;
+ }
+
+
+}
Added:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/ParametersTestBean.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/ParametersTestBean.java
(rev 0)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/beans/ParametersTestBean.java 2009-03-08
21:02:09 UTC (rev 1818)
@@ -0,0 +1,61 @@
+/**
+ * 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.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;
+
+/**
+ *
+ * @author Peter Royle
+ */
+public class ParametersTestBean {
+
+ String param1;
+ String param2;
+ String param3;
+
+ @Initializer
+ public void init(@Parameters List<String> params) {
+ Assert.assertNotNull( params );
+ Assert.assertEquals( "Unexpected number of arguments",
StartMainTest.ARGS.length, params.size() );
+ param1 = params.get( 0 );
+ param2 = params.get( 1 );
+ param3 = params.get( 2 );
+ }
+
+ public String getParam1()
+ {
+ return param1;
+ }
+
+ public String getParam2()
+ {
+ return param2;
+ }
+
+ public String getParam3()
+ {
+ return param3;
+ }
+
+}
Added: extensions/trunk/se/src/test/resources/beans.xml
===================================================================
--- extensions/trunk/se/src/test/resources/beans.xml (rev 0)
+++ extensions/trunk/se/src/test/resources/beans.xml 2009-03-08 21:02:09 UTC (rev 1818)
@@ -0,0 +1,19 @@
+<!--
+
+ 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.
+
+-->
+<beans></beans>
Added: extensions/trunk/se/src/test/resources/log4j.properties
===================================================================
--- extensions/trunk/se/src/test/resources/log4j.properties (rev
0)
+++ extensions/trunk/se/src/test/resources/log4j.properties 2009-03-08 21:02:09 UTC (rev
1818)
@@ -0,0 +1,25 @@
+#
+# 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