You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2011/07/12 04:26:35 UTC
svn commit: r1145434 - in /geronimo/server/trunk/plugins:
openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/
openwebbeans/ openwebbeans/geronimo-openwebbeans/
openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openweb...
Author: djencks
Date: Tue Jul 12 02:26:35 2011
New Revision: 1145434
URL: http://svn.apache.org/viewvc?rev=1145434&view=rev
Log:
GERONIMO-6020 set up built-in ee web beans, mostly using openejb support
Added:
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java (with props)
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java (with props)
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java (with props)
Modified:
geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoWebBeansPlugin.java
geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebInitializer.java
geronimo/server/trunk/plugins/openwebbeans/pom.xml
Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java?rev=1145434&r1=1145433&r2=1145434&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java Tue Jul 12 02:26:35 2011
@@ -24,18 +24,18 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import org.apache.geronimo.openwebbeans.GeronimoResourceInjectionService;
import org.apache.geronimo.openwebbeans.GeronimoSingletonService;
+import org.apache.geronimo.openwebbeans.GeronimoValidatorService;
import org.apache.geronimo.openwebbeans.OpenWebBeansWebInitializer;
import org.apache.geronimo.openwebbeans.OsgiMetaDataScannerService;
import org.apache.openejb.cdi.CdiAppContextsService;
import org.apache.openejb.cdi.CdiResourceInjectionService;
import org.apache.openejb.cdi.OpenEJBLifecycle;
+import org.apache.openejb.cdi.OpenEJBTransactionService;
import org.apache.openejb.cdi.StartupObject;
import org.apache.openejb.cdi.ThreadSingletonService;
import org.apache.webbeans.config.OpenWebBeansConfiguration;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.security.ManagedSecurityService;
import org.apache.webbeans.el.el22.EL22Adaptor;
import org.apache.webbeans.jsf.DefaultConversationService;
import org.apache.webbeans.spi.ContainerLifecycle;
@@ -45,9 +45,9 @@ import org.apache.webbeans.spi.JNDIServi
import org.apache.webbeans.spi.ResourceInjectionService;
import org.apache.webbeans.spi.ScannerService;
import org.apache.webbeans.spi.SecurityService;
+import org.apache.webbeans.spi.TransactionService;
+import org.apache.webbeans.spi.ValidatorService;
import org.apache.webbeans.spi.adaptor.ELAdaptor;
-import org.apache.webbeans.web.context.WebContextsService;
-import org.apache.webbeans.web.lifecycle.WebContainerLifecycle;
/**
* @version $Rev$ $Date$
@@ -77,11 +77,13 @@ public class ThreadSingletonServiceAdapt
//from CDI builder
properties.setProperty(OpenWebBeansConfiguration.INTERCEPTOR_FORCE_NO_CHECKED_EXCEPTIONS, "false");
- properties.setProperty(SecurityService.class.getName(), ManagedSecurityService.class.getName());
+ properties.setProperty(SecurityService.class.getName(), org.apache.geronimo.openwebbeans.ManagedSecurityService.class.getName());
properties.setProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY, "1800000");
properties.setProperty(OpenWebBeansConfiguration.APPLICATION_SUPPORTS_CONVERSATION, "true");
properties.setProperty(OpenWebBeansConfiguration.IGNORED_INTERFACES, "org.apache.aries.proxy.weaving.WovenProxy");
+ services.put(ValidatorService.class, new GeronimoValidatorService());
+ services.put(TransactionService.class, new OpenEJBTransactionService());
services.put(JNDIService.class, new OpenWebBeansWebInitializer.NoopJndiService());
services.put(ELAdaptor.class, new EL22Adaptor());
services.put(ConversationService.class, new DefaultConversationService());
Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml?rev=1145434&r1=1145433&r2=1145434&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml Tue Jul 12 02:26:35 2011
@@ -46,7 +46,12 @@
<artifactId>geronimo-naming</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.geronimo.framework</groupId>
+ <artifactId>geronimo-security</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.1_spec</artifactId>
@@ -170,6 +175,10 @@
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-ee</artifactId>
+ </dependency>
</dependencies>
<build>
Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java?rev=1145434&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java Tue Jul 12 02:26:35 2011
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.openwebbeans;
+
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import org.apache.webbeans.ee.event.TransactionalEventNotifier;
+import org.apache.webbeans.spi.TransactionService;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GeronimoTransactionService implements TransactionService {
+ @Override
+ public TransactionManager getTransactionManager() {
+ try {
+ return (TransactionManager) new InitialContext().lookup("java:comp/TransactionManager");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Transaction getTransaction() {
+ try {
+ return getTransactionManager().getTransaction();
+ } catch (SystemException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public UserTransaction getUserTransaction() {
+ try {
+ return (UserTransaction) new InitialContext().lookup("java:comp/env/UserTransaction");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void registerTransactionSynchronization(TransactionPhase phase, ObserverMethod<? super Object> observer, Object event) throws Exception {
+ TransactionalEventNotifier.registerTransactionSynchronization(phase, observer, event);
+ }
+}
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoTransactionService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java?rev=1145434&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java Tue Jul 12 02:26:35 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.openwebbeans;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import org.apache.webbeans.spi.ValidatorService;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GeronimoValidatorService implements ValidatorService {
+ @Override
+ public ValidatorFactory getDefaultValidatorFactory() {
+ try {
+ return (ValidatorFactory)new InitialContext().lookup("java:comp/ValidatorFactory");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Validator getDefaultValidator() {
+ try {
+ return (Validator)new InitialContext().lookup("java:comp/Validator");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoValidatorService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoWebBeansPlugin.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoWebBeansPlugin.java?rev=1145434&r1=1145433&r2=1145434&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoWebBeansPlugin.java (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/GeronimoWebBeansPlugin.java Tue Jul 12 02:26:35 2011
@@ -44,7 +44,7 @@ import org.apache.webbeans.spi.Transacti
import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
import org.apache.webbeans.spi.plugins.OpenWebBeansJavaEEPlugin;
-public class GeronimoWebBeansPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPlugin, TransactionService {
+public class GeronimoWebBeansPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPlugin {
//OpenWebBeansEjbPlugin,
public <T> Bean<T> defineSessionBean(Class<T> clazz,
ProcessAnnotatedType<T> processAnnotateTypeEvent) {
Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java?rev=1145434&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java Tue Jul 12 02:26:35 2011
@@ -0,0 +1,368 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.openwebbeans;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Properties;
+
+import javax.security.auth.Subject;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.spi.SecurityService;
+
+/**
+ * This version of the {@link org.apache.webbeans.spi.SecurityService} uses the java.lang.SecurityManager
+ * to check low level access to the underlying functions via doPriviliged blocks.
+ *
+ * The most secure way is to just copy the source over to your own class and configure
+ * it in openwebbeans.properties. This way you can add whatever security features
+ * you like to use.
+ */
+public class ManagedSecurityService implements SecurityService
+{
+ private static final int METHOD_CLASS_GETDECLAREDCONSTRUCTOR = 0x01;
+
+ private static final int METHOD_CLASS_GETDECLAREDCONSTRUCTORS = 0x02;
+
+ private static final int METHOD_CLASS_GETDECLAREDMETHOD = 0x03;
+
+ private static final int METHOD_CLASS_GETDECLAREDMETHODS = 0x04;
+
+ private static final int METHOD_CLASS_GETDECLAREDFIELD = 0x05;
+
+ private static final int METHOD_CLASS_GETDECLAREDFIELDS = 0x06;
+
+ private static final PrivilegedActionGetSystemProperties SYSTEM_PROPERTY_ACTION = new PrivilegedActionGetSystemProperties();
+
+ public ManagedSecurityService()
+ {
+ // we need to make sure that only WebBeansContext gets used to create us!
+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+
+ // in the Sun Java VM-1.6 the parent ct is alwasys entry [6]
+ // but we cannot rely on that because it might differ for
+ // other VMs.
+ boolean isCalledFromWebBeansContext = false;
+ for (int i = 3; i < 20; i++)
+ {
+ String declaringClass = stackTrace[i].getClassName();
+ String methodName = stackTrace[i].getMethodName();
+ if (declaringClass.equals(WebBeansContext.class.getName()) &&
+ methodName.equals("<init>"))
+ {
+ isCalledFromWebBeansContext = true;
+ break;
+ }
+ }
+ if (!isCalledFromWebBeansContext)
+ {
+ throw new SecurityException("ManagedSecurityService must directly get created by WebBeansContext!");
+ }
+
+ // we also need to make sure that this very class didn't get subclassed
+ // to prevent man in the middle attacks
+ if (this.getClass() != ManagedSecurityService.class)
+ {
+ throw new SecurityException("ManagedSecurityService must not get subclassed!");
+ }
+ }
+
+ @Override
+ public Principal getCurrentPrincipal()
+ {
+ Subject callerSubject = ContextManager.getCurrentCaller();
+ return ContextManager.getCurrentPrincipal(callerSubject);
+ }
+
+ @Override
+ public <T> Constructor<T> doPrivilegedGetDeclaredConstructor(Class<T> clazz, Class<?>... parameterTypes)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, parameterTypes, METHOD_CLASS_GETDECLAREDCONSTRUCTOR));
+ if (obj instanceof NoSuchMethodException)
+ {
+ return null;
+ }
+ return (Constructor<T>)obj;
+ }
+
+ @Override
+ public <T> Constructor<?>[] doPrivilegedGetDeclaredConstructors(Class<T> clazz)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDCONSTRUCTORS));
+ return (Constructor<T>[])obj;
+ }
+
+ @Override
+ public <T> Method doPrivilegedGetDeclaredMethod(Class<T> clazz, String name, Class<?>... parameterTypes)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, new Object[] {name, parameterTypes}, METHOD_CLASS_GETDECLAREDMETHOD));
+ if (obj instanceof NoSuchMethodException)
+ {
+ return null;
+ }
+ return (Method)obj;
+ }
+
+ @Override
+ public <T> Method[] doPrivilegedGetDeclaredMethods(Class<T> clazz)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDMETHODS));
+ return (Method[])obj;
+ }
+
+ @Override
+ public <T> Field doPrivilegedGetDeclaredField(Class<T> clazz, String name)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, name, METHOD_CLASS_GETDECLAREDFIELD));
+ if (obj instanceof NoSuchFieldException)
+ {
+ return null;
+ }
+ return (Field)obj;
+ }
+
+ @Override
+ public <T> Field[] doPrivilegedGetDeclaredFields(Class<T> clazz)
+ {
+ Object obj = AccessController.doPrivileged(
+ new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDFIELDS));
+ return (Field[])obj;
+ }
+
+ @Override
+ public void doPrivilegedSetAccessible(AccessibleObject obj, boolean flag)
+ {
+ AccessController.doPrivileged(new PrivilegedActionForSetAccessible(obj, flag));
+ }
+
+ @Override
+ public boolean doPrivilegedIsAccessible(AccessibleObject obj)
+ {
+ return (Boolean) AccessController.doPrivileged(new PrivilegedActionForIsAccessible(obj));
+ }
+
+ @Override
+ public <T> T doPrivilegedObjectCreate(Class<T> clazz) throws PrivilegedActionException, IllegalAccessException, InstantiationException
+ {
+ return (T) AccessController.doPrivileged(new PrivilegedActionForObjectCreation(clazz));
+ }
+
+ @Override
+ public void doPrivilegedSetSystemProperty(String propertyName, String value)
+ {
+ AccessController.doPrivileged(new PrivilegedActionForSetProperty(propertyName, value));
+ }
+
+ @Override
+ public String doPrivilegedGetSystemProperty(String propertyName, String defaultValue)
+ {
+ return AccessController.doPrivileged(new PrivilegedActionForProperty(propertyName, defaultValue));
+ }
+
+ @Override
+ public Properties doPrivilegedGetSystemProperties()
+ {
+ return AccessController.doPrivileged(SYSTEM_PROPERTY_ACTION);
+ }
+
+
+ // the following block contains internal wrapper classes for doPrivileged actions
+
+ protected static class PrivilegedActionForClass implements PrivilegedAction<Object>
+ {
+ private Class<?> clazz;
+
+ private Object parameters;
+
+ private int method;
+
+ protected PrivilegedActionForClass(Class<?> clazz, Object parameters, int method)
+ {
+ this.clazz = clazz;
+ this.parameters = parameters;
+ this.method = method;
+ }
+
+ public Object run()
+ {
+ try
+ {
+ switch (method)
+ {
+ case METHOD_CLASS_GETDECLAREDCONSTRUCTOR:
+ return clazz.getDeclaredConstructor((Class<?>[])parameters);
+ case METHOD_CLASS_GETDECLAREDCONSTRUCTORS:
+ return clazz.getDeclaredConstructors();
+ case METHOD_CLASS_GETDECLAREDMETHOD:
+ String name = (String)((Object[])parameters)[0];
+ Class<?>[] realParameters = (Class<?>[])((Object[])parameters)[1];
+ return clazz.getDeclaredMethod(name, realParameters);
+ case METHOD_CLASS_GETDECLAREDMETHODS:
+ return clazz.getDeclaredMethods();
+ case METHOD_CLASS_GETDECLAREDFIELD:
+ return clazz.getDeclaredField((String)parameters);
+ case METHOD_CLASS_GETDECLAREDFIELDS:
+ return clazz.getDeclaredFields();
+
+ default:
+ return new WebBeansException("unknown security method: " + method);
+ }
+ }
+ catch (Exception exception)
+ {
+ return exception;
+ }
+ }
+
+ }
+
+ protected static class PrivilegedActionForSetAccessible implements PrivilegedAction<Object>
+ {
+
+ private AccessibleObject object;
+
+ private boolean flag;
+
+ protected PrivilegedActionForSetAccessible(AccessibleObject object, boolean flag)
+ {
+ this.object = object;
+ this.flag = flag;
+ }
+
+ public Object run()
+ {
+ object.setAccessible(flag);
+ return null;
+ }
+ }
+
+ protected static class PrivilegedActionForIsAccessible implements PrivilegedAction<Object>
+ {
+
+ private AccessibleObject object;
+
+ protected PrivilegedActionForIsAccessible(AccessibleObject object)
+ {
+ this.object = object;
+ }
+
+ public Object run()
+ {
+ return object.isAccessible();
+ }
+ }
+
+ protected static class PrivilegedActionForProperty implements PrivilegedAction<String>
+ {
+ private final String propertyName;
+
+ private final String defaultValue;
+
+ protected PrivilegedActionForProperty(String propertyName, String defaultValue)
+ {
+ this.propertyName = propertyName;
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public String run()
+ {
+ return System.getProperty(this.propertyName,this.defaultValue);
+ }
+
+ }
+
+ protected static class PrivilegedActionForSetProperty implements PrivilegedAction<Object>
+ {
+ private final String propertyName;
+
+ private final String value;
+
+ protected PrivilegedActionForSetProperty(String propertyName, String value)
+ {
+ this.propertyName = propertyName;
+ this.value = value;
+ }
+
+ @Override
+ public String run()
+ {
+ System.setProperty(propertyName, value);
+ return null;
+ }
+
+ }
+
+ protected static class PrivilegedActionGetSystemProperties implements PrivilegedAction<Properties>
+ {
+
+ @Override
+ public Properties run()
+ {
+ return System.getProperties();
+ }
+
+ }
+
+ protected static class PrivilegedActionForObjectCreation implements PrivilegedExceptionAction<Object>
+ {
+ private Class<?> clazz;
+
+ protected PrivilegedActionForObjectCreation(Class<?> clazz)
+ {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public Object run() throws Exception
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw e;
+ }
+ catch (IllegalAccessException e)
+ {
+ throw e;
+ }
+ }
+
+ }
+
+
+}
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/ManagedSecurityService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebInitializer.java?rev=1145434&r1=1145433&r2=1145434&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebInitializer.java (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebInitializer.java Tue Jul 12 02:26:35 2011
@@ -19,7 +19,6 @@
package org.apache.geronimo.openwebbeans;
-import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -28,7 +27,6 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import org.apache.webbeans.config.OpenWebBeansConfiguration;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.security.ManagedSecurityService;
import org.apache.webbeans.el.el22.EL22Adaptor;
import org.apache.webbeans.jsf.DefaultConversationService;
import org.apache.webbeans.spi.ContainerLifecycle;
@@ -38,6 +36,8 @@ import org.apache.webbeans.spi.JNDIServi
import org.apache.webbeans.spi.ResourceInjectionService;
import org.apache.webbeans.spi.ScannerService;
import org.apache.webbeans.spi.SecurityService;
+import org.apache.webbeans.spi.TransactionService;
+import org.apache.webbeans.spi.ValidatorService;
import org.apache.webbeans.spi.adaptor.ELAdaptor;
import org.apache.webbeans.util.WebBeansUtil;
import org.apache.webbeans.web.context.WebContextsService;
@@ -52,11 +52,13 @@ public class OpenWebBeansWebInitializer
Properties properties = new Properties();
Map<Class<?>, Object> services = new HashMap<Class<?>, Object>();
properties.setProperty(OpenWebBeansConfiguration.APPLICATION_IS_JSP, "true");
- properties.setProperty(SecurityService.class.getName(), ManagedSecurityService.class.getName());
+ properties.setProperty(SecurityService.class.getName(), org.apache.geronimo.openwebbeans.ManagedSecurityService.class.getName());
properties.setProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY, "1800000");
properties.setProperty(OpenWebBeansConfiguration.APPLICATION_SUPPORTS_CONVERSATION, "true");
properties.setProperty(OpenWebBeansConfiguration.IGNORED_INTERFACES, "org.apache.aries.proxy.weaving.WovenProxy");
+ services.put(ValidatorService.class, new GeronimoValidatorService());
+ services.put(TransactionService.class, new GeronimoTransactionService());
services.put(JNDIService.class, new NoopJndiService());
services.put(ELAdaptor.class, new EL22Adaptor());
services.put(ConversationService.class, new DefaultConversationService());
Modified: geronimo/server/trunk/plugins/openwebbeans/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/pom.xml?rev=1145434&r1=1145433&r2=1145434&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/pom.xml (original)
+++ geronimo/server/trunk/plugins/openwebbeans/pom.xml Tue Jul 12 02:26:35 2011
@@ -82,6 +82,11 @@
<artifactId>openwebbeans-resource</artifactId>
<version>${openwebbeansVersion}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-ee</artifactId>
+ <version>${openwebbeansVersion}</version>
+ </dependency>
</dependencies>
</dependencyManagement>