You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2009/08/27 05:42:11 UTC
svn commit: r808273 [1/5] - in /openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/config/
container/openejb-core/src/main/java/org/apache/openejb/config/rules/
container/openejb-core/src/main/java/org/apache/openejb/core/e...
Author: dblevins
Date: Thu Aug 27 03:42:06 2009
New Revision: 808273
URL: http://svn.apache.org/viewvc?rev=808273&view=rev
Log:
ran dos2unix on the files to get them into native line endings
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/MappedNameBuilder.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NamingException.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/Instance.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoSecurityService.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoTransactionService.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PropertiesService.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/MappedNameBuilderTest.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java
openejb/trunk/openejb3/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonImpl.java
openejb/trunk/openejb3/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java
openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java
openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java
openejb/trunk/openejb3/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java
openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/ChatBean.java
openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientBean.java
openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientLocal.java
openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/test/java/org/superbiz/mdb/ChatBeanTest.java
openejb/trunk/openejb3/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorImpl.java
openejb/trunk/openejb3/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorLocal.java
openejb/trunk/openejb3/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorRemote.java
openejb/trunk/openejb3/examples/simple-stateless-with-descriptor/src/test/java/org/superbiz/calculator/CalculatorTest.java
openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/ApplicationException.java
openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java
openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbObject.java
openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInterceptor.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbInterceptorTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedFieldInjectionSingletonLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedFieldInjectionSingletonPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedFieldInjectionSingletonPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedFieldInjectionSingletonTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedSetterInjectionSingletonLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedSetterInjectionSingletonPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedSetterInjectionSingletonPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/singleton/AnnotatedSetterInjectionSingletonTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedSetterInjectionStatefulLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedSetterInjectionStatefulPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedSetterInjectionStatefulPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/AnnotatedSetterInjectionStatefulTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateful/StatefulPojoLocalIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedFieldInjectionStatelessLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedFieldInjectionStatelessPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedFieldInjectionStatelessPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedFieldInjectionStatelessTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedSetterInjectionStatelessLocalTestClient.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedSetterInjectionStatelessPojoHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedSetterInjectionStatelessPojoLocalHomeIntfcTests.java
openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/AnnotatedSetterInjectionStatelessTestClient.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ConfigureCxfSecurity.java
openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Restart.java
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Status.java
openejb/trunk/openejb3/server/openejb-telnet/src/main/java/org/apache/openejb/server/telnet/TelnetOption.java
openejb/trunk/openejb3/server/openejb-telnet/src/main/java/org/apache/openejb/server/telnet/TelnetServer.java
openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/MappedNameBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/MappedNameBuilder.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/MappedNameBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/MappedNameBuilder.java Thu Aug 27 03:42:06 2009
@@ -1,55 +1,55 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.openejb.config;
-
-import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.jee.oejb3.EjbDeployment;
-import org.apache.openejb.jee.oejb3.Jndi;
-import org.apache.openejb.jee.oejb3.OpenejbJar;
-import org.apache.openejb.jee.EnterpriseBean;
-
-import java.util.Map;
-
-public class MappedNameBuilder implements DynamicDeployer{
- public AppModule deploy(AppModule appModule) throws OpenEJBException {
- for (EjbModule ejbModule : appModule.getEjbModules()) {
- OpenejbJar openejbJar = ejbModule.getOpenejbJar();
- if (openejbJar == null) {
- return appModule;
- }
-
- Map<String, EjbDeployment> ejbDeployments = openejbJar.getDeploymentsByEjbName();
- for (EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
- EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
-
- if (ejbDeployment == null) {
- continue;
- }
-
- String mappedName = enterpriseBean.getMappedName();
-
- if (mappedName != null && mappedName.length() > 0) {
- ejbDeployment.getJndi().add(new Jndi(mappedName, "Remote"));
- }
- }
- }
-
- return appModule;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openejb.config;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.jee.oejb3.EjbDeployment;
+import org.apache.openejb.jee.oejb3.Jndi;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+
+import java.util.Map;
+
+public class MappedNameBuilder implements DynamicDeployer{
+ public AppModule deploy(AppModule appModule) throws OpenEJBException {
+ for (EjbModule ejbModule : appModule.getEjbModules()) {
+ OpenejbJar openejbJar = ejbModule.getOpenejbJar();
+ if (openejbJar == null) {
+ return appModule;
+ }
+
+ Map<String, EjbDeployment> ejbDeployments = openejbJar.getDeploymentsByEjbName();
+ for (EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
+ EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
+
+ if (ejbDeployment == null) {
+ continue;
+ }
+
+ String mappedName = enterpriseBean.getMappedName();
+
+ if (mappedName != null && mappedName.length() > 0) {
+ ejbDeployment.getJndi().add(new Jndi(mappedName, "Remote"));
+ }
+ }
+ }
+
+ return appModule;
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckUserTransactionRefs.java Thu Aug 27 03:42:06 2009
@@ -1,51 +1,51 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.config.rules;
-
-import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.jee.EnterpriseBean;
-import org.apache.openejb.jee.ResourceEnvRef;
-import org.apache.openejb.jee.ResourceRef;
-import static org.apache.openejb.jee.TransactionType.CONTAINER;
-
-import java.util.Collection;
-
-/**
- * Excerpt from EJB 3.0 Core spec, chapter <b>16.12. UserTransaction Interface</b>:
- * <p>
- * <i>The container must make the UserTransaction interface available to the enterprise beans that are
- * allowed to use this interface (only session and message-driven beans with bean-managed transaction
- * demarcation are allowed to use this interface)</i>
- * </p>
- *
- * @version $Rev$ $Date$
- */
-public class CheckUserTransactionRefs extends ValidationBase {
-
- public void validate(EjbModule ejbModule) {
- for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
- if (bean.getTransactionType() == CONTAINER) {
- Collection<ResourceRef> resRefs = bean.getResourceRef();
- for (ResourceRef resRef : resRefs) {
- if ("javax.transaction.UserTransaction".equals(resRef.getResType())) {
- error(bean, "userResourceRef.forbiddenForCmtdBeans", resRef.getName());
- }
- }
- }
- }
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.config.rules;
+
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.ResourceEnvRef;
+import org.apache.openejb.jee.ResourceRef;
+import static org.apache.openejb.jee.TransactionType.CONTAINER;
+
+import java.util.Collection;
+
+/**
+ * Excerpt from EJB 3.0 Core spec, chapter <b>16.12. UserTransaction Interface</b>:
+ * <p>
+ * <i>The container must make the UserTransaction interface available to the enterprise beans that are
+ * allowed to use this interface (only session and message-driven beans with bean-managed transaction
+ * demarcation are allowed to use this interface)</i>
+ * </p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class CheckUserTransactionRefs extends ValidationBase {
+
+ public void validate(EjbModule ejbModule) {
+ for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
+ if (bean.getTransactionType() == CONTAINER) {
+ Collection<ResourceRef> resRefs = bean.getResourceRef();
+ for (ResourceRef resRef : resRefs) {
+ if ("javax.transaction.UserTransaction".equals(resRef.getResType())) {
+ error(bean, "userResourceRef.forbiddenForCmtdBeans", resRef.getName());
+ }
+ }
+ }
+ }
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java Thu Aug 27 03:42:06 2009
@@ -1,155 +1,155 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.core.entity;
-
-import java.lang.reflect.Method;
-import java.util.Vector;
-import java.util.List;
-
-import org.apache.openejb.ProxyInfo;
-import org.apache.openejb.InterfaceType;
-import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.DeploymentInfo;
-import org.apache.openejb.core.ivm.EjbHomeProxyHandler;
-import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
-import org.apache.openejb.core.ivm.IntraVmProxy;
-import org.apache.openejb.util.proxy.ProxyManager;
-import org.apache.openejb.util.proxy.InvocationHandler;
-
-import javax.ejb.EJBLocalObject;
-import javax.ejb.RemoveException;
-import javax.ejb.EJBObject;
-
-
-public class EntityEjbHomeHandler extends EjbHomeProxyHandler {
-
- public EntityEjbHomeHandler(DeploymentInfo deploymentInfo, InterfaceType interfaceType, List<Class> interfaces) {
- super(deploymentInfo, interfaceType, interfaces);
- }
-
- public Object createProxy(Object primaryKey) {
- Object proxy = super.createProxy(primaryKey);
- EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(proxy);
-
- /*
- * Register the handle with the BaseEjbProxyHandler.liveHandleRegistry
- * If the bean is removed by its home or by an identical proxy, then the
- * this proxy will be automatically invalidated because its properly registered
- * with the liveHandleRegistry.
- */
- registerHandler(handler.getRegistryId(), handler);
-
- return proxy;
-
- }
-
- protected Object findX(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
- Object retValue;
- try {
- retValue = container.invoke(deploymentID, interfaceType, interfce, method, args, null);
- } catch (OpenEJBException e) {
- logger.debug("entityEjbHomeHandler.containerInvocationFailure", e, e.getMessage());
- throw e;
- }
-
- if (retValue instanceof java.util.Collection) {
- Object [] proxyInfos = ((java.util.Collection) retValue).toArray();
- Vector proxies = new Vector();
- for (int i = 0; i < proxyInfos.length; i++) {
- ProxyInfo proxyInfo = (ProxyInfo) proxyInfos[i];
- proxies.addElement(createProxy(proxyInfo.getPrimaryKey()));
- }
- return proxies;
- } else if (retValue instanceof org.apache.openejb.util.ArrayEnumeration) {
- org.apache.openejb.util.ArrayEnumeration enumeration = (org.apache.openejb.util.ArrayEnumeration) retValue;
- for (int i = enumeration.size() - 1; i >= 0; --i) {
- ProxyInfo proxyInfo = ((ProxyInfo) enumeration.get(i));
- enumeration.set(i, createProxy(proxyInfo.getPrimaryKey()));
- }
- return enumeration;
- } else if (retValue instanceof java.util.Enumeration) {
- java.util.Enumeration enumeration = (java.util.Enumeration) retValue;
-
- java.util.List proxies = new java.util.ArrayList();
- while (enumeration.hasMoreElements()) {
- ProxyInfo proxyInfo = ((ProxyInfo) enumeration.nextElement());
- proxies.add(createProxy(proxyInfo.getPrimaryKey()));
- }
- return new org.apache.openejb.util.ArrayEnumeration(proxies);
- } else {
- org.apache.openejb.ProxyInfo proxyInfo = (org.apache.openejb.ProxyInfo) retValue;
-
-
- return createProxy(proxyInfo.getPrimaryKey());
- }
-
- }
-
- protected Object removeByPrimaryKey(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
- Object primKey = args[0];
-
- // Check for the common mistake of passing the ejbObject instead of ejbObject.getPrimaryKey()
- if (primKey instanceof EJBLocalObject) {
- Class ejbObjectProxyClass = primKey.getClass();
-
- String ejbObjectName = null;
- for (Class clazz : ejbObjectProxyClass.getInterfaces()) {
- if (EJBLocalObject.class.isAssignableFrom(clazz)) {
- ejbObjectName = clazz.getSimpleName();
- break;
- }
- }
-
- throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbLocalHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
-
- } else if (primKey instanceof EJBObject) {
- Class ejbObjectProxyClass = primKey.getClass();
-
- String ejbObjectName = null;
- for (Class clazz : ejbObjectProxyClass.getInterfaces()) {
- if (EJBObject.class.isAssignableFrom(clazz)) {
- ejbObjectName = clazz.getSimpleName();
- break;
- }
- }
-
- throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
- }
-
- container.invoke(deploymentID, interfaceType, interfce, method, args, primKey);
-
- /*
- * This operation takes care of invalidating all the EjbObjectProxyHanders associated with
- * the same RegistryId. See this.createProxy().
- */
- invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(container, deploymentID, primKey));
- return null;
- }
-
- private static String lcfirst(String s){
- if (s == null || s.length() < 1) return s;
-
- StringBuilder sb = new StringBuilder(s);
- sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
- return sb.toString();
- }
-
- protected EjbObjectProxyHandler newEjbObjectHandler(DeploymentInfo deploymentInfo, Object pk, InterfaceType interfaceType, List<Class> interfaces) {
- return new EntityEjbObjectHandler(getDeploymentInfo(), pk, interfaceType, interfaces);
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.core.entity;
+
+import java.lang.reflect.Method;
+import java.util.Vector;
+import java.util.List;
+
+import org.apache.openejb.ProxyInfo;
+import org.apache.openejb.InterfaceType;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.core.ivm.EjbHomeProxyHandler;
+import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
+import org.apache.openejb.core.ivm.IntraVmProxy;
+import org.apache.openejb.util.proxy.ProxyManager;
+import org.apache.openejb.util.proxy.InvocationHandler;
+
+import javax.ejb.EJBLocalObject;
+import javax.ejb.RemoveException;
+import javax.ejb.EJBObject;
+
+
+public class EntityEjbHomeHandler extends EjbHomeProxyHandler {
+
+ public EntityEjbHomeHandler(DeploymentInfo deploymentInfo, InterfaceType interfaceType, List<Class> interfaces) {
+ super(deploymentInfo, interfaceType, interfaces);
+ }
+
+ public Object createProxy(Object primaryKey) {
+ Object proxy = super.createProxy(primaryKey);
+ EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(proxy);
+
+ /*
+ * Register the handle with the BaseEjbProxyHandler.liveHandleRegistry
+ * If the bean is removed by its home or by an identical proxy, then the
+ * this proxy will be automatically invalidated because its properly registered
+ * with the liveHandleRegistry.
+ */
+ registerHandler(handler.getRegistryId(), handler);
+
+ return proxy;
+
+ }
+
+ protected Object findX(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+ Object retValue;
+ try {
+ retValue = container.invoke(deploymentID, interfaceType, interfce, method, args, null);
+ } catch (OpenEJBException e) {
+ logger.debug("entityEjbHomeHandler.containerInvocationFailure", e, e.getMessage());
+ throw e;
+ }
+
+ if (retValue instanceof java.util.Collection) {
+ Object [] proxyInfos = ((java.util.Collection) retValue).toArray();
+ Vector proxies = new Vector();
+ for (int i = 0; i < proxyInfos.length; i++) {
+ ProxyInfo proxyInfo = (ProxyInfo) proxyInfos[i];
+ proxies.addElement(createProxy(proxyInfo.getPrimaryKey()));
+ }
+ return proxies;
+ } else if (retValue instanceof org.apache.openejb.util.ArrayEnumeration) {
+ org.apache.openejb.util.ArrayEnumeration enumeration = (org.apache.openejb.util.ArrayEnumeration) retValue;
+ for (int i = enumeration.size() - 1; i >= 0; --i) {
+ ProxyInfo proxyInfo = ((ProxyInfo) enumeration.get(i));
+ enumeration.set(i, createProxy(proxyInfo.getPrimaryKey()));
+ }
+ return enumeration;
+ } else if (retValue instanceof java.util.Enumeration) {
+ java.util.Enumeration enumeration = (java.util.Enumeration) retValue;
+
+ java.util.List proxies = new java.util.ArrayList();
+ while (enumeration.hasMoreElements()) {
+ ProxyInfo proxyInfo = ((ProxyInfo) enumeration.nextElement());
+ proxies.add(createProxy(proxyInfo.getPrimaryKey()));
+ }
+ return new org.apache.openejb.util.ArrayEnumeration(proxies);
+ } else {
+ org.apache.openejb.ProxyInfo proxyInfo = (org.apache.openejb.ProxyInfo) retValue;
+
+
+ return createProxy(proxyInfo.getPrimaryKey());
+ }
+
+ }
+
+ protected Object removeByPrimaryKey(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+ Object primKey = args[0];
+
+ // Check for the common mistake of passing the ejbObject instead of ejbObject.getPrimaryKey()
+ if (primKey instanceof EJBLocalObject) {
+ Class ejbObjectProxyClass = primKey.getClass();
+
+ String ejbObjectName = null;
+ for (Class clazz : ejbObjectProxyClass.getInterfaces()) {
+ if (EJBLocalObject.class.isAssignableFrom(clazz)) {
+ ejbObjectName = clazz.getSimpleName();
+ break;
+ }
+ }
+
+ throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbLocalHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
+
+ } else if (primKey instanceof EJBObject) {
+ Class ejbObjectProxyClass = primKey.getClass();
+
+ String ejbObjectName = null;
+ for (Class clazz : ejbObjectProxyClass.getInterfaces()) {
+ if (EJBObject.class.isAssignableFrom(clazz)) {
+ ejbObjectName = clazz.getSimpleName();
+ break;
+ }
+ }
+
+ throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
+ }
+
+ container.invoke(deploymentID, interfaceType, interfce, method, args, primKey);
+
+ /*
+ * This operation takes care of invalidating all the EjbObjectProxyHanders associated with
+ * the same RegistryId. See this.createProxy().
+ */
+ invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(container, deploymentID, primKey));
+ return null;
+ }
+
+ private static String lcfirst(String s){
+ if (s == null || s.length() < 1) return s;
+
+ StringBuilder sb = new StringBuilder(s);
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ return sb.toString();
+ }
+
+ protected EjbObjectProxyHandler newEjbObjectHandler(DeploymentInfo deploymentInfo, Object pk, InterfaceType interfaceType, List<Class> interfaces) {
+ return new EntityEjbObjectHandler(getDeploymentInfo(), pk, interfaceType, interfaces);
+ }
+
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NamingException.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NamingException.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NamingException.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NamingException.java Thu Aug 27 03:42:06 2009
@@ -14,34 +14,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.openejb.core.ivm.naming;
-
-public class NamingException extends javax.naming.NamingException {
- private org.apache.openejb.OpenEJBException delegate;
-
- public NamingException(String message, org.apache.openejb.OpenEJBException delegateArg) {
- super();
- delegate = delegateArg;
- }
-
- public NamingException(String message, Throwable rootCause) {
- super();
- delegate = new org.apache.openejb.OpenEJBException(message, rootCause);
- }
-
- public String getMessage() {
- return delegate.getMessage();
- }
-
- public void printStackTrace() {
- delegate.printStackTrace();
- }
-
- public void printStackTrace(java.io.PrintStream stream) {
- delegate.printStackTrace(stream);
- }
-
- public void printStackTrace(java.io.PrintWriter writer) {
- delegate.printStackTrace(writer);
- }
-}
+package org.apache.openejb.core.ivm.naming;
+
+public class NamingException extends javax.naming.NamingException {
+ private org.apache.openejb.OpenEJBException delegate;
+
+ public NamingException(String message, org.apache.openejb.OpenEJBException delegateArg) {
+ super();
+ delegate = delegateArg;
+ }
+
+ public NamingException(String message, Throwable rootCause) {
+ super();
+ delegate = new org.apache.openejb.OpenEJBException(message, rootCause);
+ }
+
+ public String getMessage() {
+ return delegate.getMessage();
+ }
+
+ public void printStackTrace() {
+ delegate.printStackTrace();
+ }
+
+ public void printStackTrace(java.io.PrintStream stream) {
+ delegate.printStackTrace(stream);
+ }
+
+ public void printStackTrace(java.io.PrintWriter writer) {
+ delegate.printStackTrace(writer);
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/Instance.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/Instance.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/Instance.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/Instance.java Thu Aug 27 03:42:06 2009
@@ -1,32 +1,32 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.core.mdb;
-
-import java.util.Map;
-
-/**
- * @version $Rev$ $Date$
- */
-public class Instance {
- public final Object bean;
- public final Map<String,Object> interceptors;
-
- public Instance(Object bean, Map<String, Object> interceptors) {
- this.bean = bean;
- this.interceptors = interceptors;
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.core.mdb;
+
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Instance {
+ public final Object bean;
+ public final Map<String,Object> interceptors;
+
+ public Instance(Object bean, Map<String, Object> interceptors) {
+ this.bean = bean;
+ this.interceptors = interceptors;
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoSecurityService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoSecurityService.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoSecurityService.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoSecurityService.java Thu Aug 27 03:42:06 2009
@@ -1,73 +1,73 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.ri.sp;
-
-import org.apache.openejb.spi.SecurityService;
-import org.apache.openejb.InterfaceType;
-
-import javax.security.auth.login.LoginException;
-import java.util.Collection;
-import java.util.Set;
-import java.util.Collections;
-import java.security.Principal;
-import java.lang.reflect.Method;
-
-/**
- * @org.apache.xbean.XBean element="pseudoSecurityService"
- */
-public class PseudoSecurityService implements SecurityService {
- public PseudoSecurityService() {
- PseudoPolicyConfigurationFactory.install();
- }
-
- public void init(java.util.Properties props) {
- }
-
- public Object login(String user, String pass) throws LoginException {
- return null;
- }
-
- public Object login(String securityRealm, String user, String pass) throws LoginException {
- return null;
- }
-
- public Set<String> getLogicalRoles(Principal[] principals, Set<String> logicalRoles) {
- return Collections.emptySet();
- }
-
- public void associate(Object securityIdentity) throws LoginException {
- }
-
- public Object disassociate() {
- return null;
- }
-
- public void logout(Object securityIdentity) throws LoginException {
- }
-
- public boolean isCallerInRole(String role) {
- return false;
- }
-
- public Principal getCallerPrincipal() {
- return null;
- }
-
- public boolean isCallerAuthorized(Method method, InterfaceType type) {
- return true;
- }
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.ri.sp;
+
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.InterfaceType;
+
+import javax.security.auth.login.LoginException;
+import java.util.Collection;
+import java.util.Set;
+import java.util.Collections;
+import java.security.Principal;
+import java.lang.reflect.Method;
+
+/**
+ * @org.apache.xbean.XBean element="pseudoSecurityService"
+ */
+public class PseudoSecurityService implements SecurityService {
+ public PseudoSecurityService() {
+ PseudoPolicyConfigurationFactory.install();
+ }
+
+ public void init(java.util.Properties props) {
+ }
+
+ public Object login(String user, String pass) throws LoginException {
+ return null;
+ }
+
+ public Object login(String securityRealm, String user, String pass) throws LoginException {
+ return null;
+ }
+
+ public Set<String> getLogicalRoles(Principal[] principals, Set<String> logicalRoles) {
+ return Collections.emptySet();
+ }
+
+ public void associate(Object securityIdentity) throws LoginException {
+ }
+
+ public Object disassociate() {
+ return null;
+ }
+
+ public void logout(Object securityIdentity) throws LoginException {
+ }
+
+ public boolean isCallerInRole(String role) {
+ return false;
+ }
+
+ public Principal getCallerPrincipal() {
+ return null;
+ }
+
+ public boolean isCallerAuthorized(Method method, InterfaceType type) {
+ return true;
+ }
}
\ No newline at end of file
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoTransactionService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoTransactionService.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoTransactionService.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/ri/sp/PseudoTransactionService.java Thu Aug 27 03:42:06 2009
@@ -1,312 +1,312 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.ri.sp;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.TransactionSynchronizationRegistry;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-
-import org.apache.openejb.spi.TransactionService;
-import org.apache.openejb.util.LogCategory;
-import org.apache.openejb.util.Logger;
-
-/**
- * @org.apache.xbean.XBean element="pseudoTransactionService"
- */
-public class PseudoTransactionService implements TransactionService, TransactionManager, TransactionSynchronizationRegistry {
- private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.core.cmp");
- private final ThreadLocal<MyTransaction> threadTransaction = new ThreadLocal<MyTransaction>();
-
- public void init(Properties props) {
- }
-
- public TransactionManager getTransactionManager() {
- return this;
- }
-
- public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
- return this;
- }
-
- public int getStatus() {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- return Status.STATUS_NO_TRANSACTION;
- }
- return tx.getStatus();
- }
-
- public Transaction getTransaction() {
- return threadTransaction.get();
- }
-
- public boolean getRollbackOnly() {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
- return tx.getRollbackOnly();
- }
-
- public void setRollbackOnly() {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
- tx.setRollbackOnly();
- }
-
- public void begin() throws NotSupportedException {
- if (threadTransaction.get() != null) {
- throw new NotSupportedException("A transaction is already active");
- }
-
- MyTransaction tx = new MyTransaction();
- threadTransaction.set(tx);
- }
-
- public void commit() throws RollbackException {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
-
- try {
- tx.commit();
- } finally {
- threadTransaction.set(null);
- }
- }
-
-
- public void rollback() {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
-
- try {
- tx.rollback();
- } finally {
- threadTransaction.set(null);
- }
- }
-
- public Transaction suspend() {
- return threadTransaction.get();
- }
-
- public void resume(Transaction tx) throws InvalidTransactionException {
- if (tx == null) {
- throw new InvalidTransactionException("Transaction is null");
- }
- if (!(tx instanceof MyTransaction)) {
- throw new InvalidTransactionException("Unknown transaction type " + tx.getClass().getName());
- }
- MyTransaction myTransaction = (MyTransaction) tx;
-
- if (threadTransaction.get() != null) {
- throw new IllegalStateException("A transaction is already active");
- }
-
- int status = myTransaction.getStatus();
- if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) {
- throw new InvalidTransactionException("Expected transaction to be STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, but was " + status);
- }
-
- threadTransaction.set(myTransaction);
- }
-
- public Object getTransactionKey() {
- return getTransaction();
- }
-
- public int getTransactionStatus() {
- return getStatus();
- }
-
- public Object getResource(Object key) {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
-
- Object value = tx.getResource(key);
- return value;
- }
-
- public void putResource(Object key, Object value) {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
-
- tx.putResource(key, value);
- }
-
- public void registerInterposedSynchronization(Synchronization synchronization) {
- MyTransaction tx = threadTransaction.get();
- if (tx == null) {
- throw new IllegalStateException("No transaction active");
- }
-
- tx.registerInterposedSynchronization(synchronization);
- }
-
- public void setTransactionTimeout(int seconds) {
- }
-
- public class MyTransaction implements Transaction {
- private final List<Synchronization> registeredSynchronizations = Collections.synchronizedList(new ArrayList<Synchronization>());
- private final List<XAResource> xaResources = Collections.synchronizedList(new ArrayList<XAResource>());
- private final Map<Object, Object> resources = new HashMap<Object,Object>();
- private int status = Status.STATUS_ACTIVE;
-
- public boolean delistResource(XAResource xaRes, int flag) {
- xaResources.remove(xaRes);
- return true;
- }
-
- public boolean enlistResource(XAResource xaRes) {
- xaResources.add(xaRes);
- return true;
- }
-
- public int getStatus() {
- return status;
- }
-
- public void registerSynchronization(Synchronization synchronization) {
- registeredSynchronizations.add(synchronization);
- }
-
- public void registerInterposedSynchronization(Synchronization synchronization) {
- registeredSynchronizations.add(synchronization);
- }
-
- public boolean getRollbackOnly() {
- return status == Status.STATUS_MARKED_ROLLBACK;
- }
-
- public void setRollbackOnly() {
- status = Status.STATUS_MARKED_ROLLBACK;
- }
-
- public Object getResource(Object key) {
- if (key == null) throw new NullPointerException("key is null");
- return resources.get(key);
- }
-
- public void putResource(Object key, Object value) {
- if (key == null) throw new NullPointerException("key is null");
- if (value != null) {
- resources.put(key, value);
- } else {
- resources.remove(key);
- }
- }
-
- public void commit() throws RollbackException {
- try {
- if (status == Status.STATUS_MARKED_ROLLBACK) {
- rollback();
- throw new RollbackException();
- }
- try {
- doBeforeCompletion();
- } catch (Exception e) {
- rollback();
- throw (RollbackException) new RollbackException().initCause(e);
- }
- doXAResources(Status.STATUS_COMMITTED);
- status = Status.STATUS_COMMITTED;
- doAfterCompletion(Status.STATUS_COMMITTED);
- } finally {
- threadTransaction.set(null);
- }
- }
-
- public void rollback() {
- try {
- doXAResources(Status.STATUS_ROLLEDBACK);
- doAfterCompletion(Status.STATUS_ROLLEDBACK);
- status = Status.STATUS_ROLLEDBACK;
- registeredSynchronizations.clear();
- } finally {
- threadTransaction.set(null);
- }
- }
-
- private void doBeforeCompletion() {
- for (Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
- sync.beforeCompletion();
- }
- }
-
- private void doAfterCompletion(int status) {
- for (Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
- try {
- sync.afterCompletion(status);
- } catch (RuntimeException e) {
- logger.warning("Synchronization afterCompletion threw a RuntimeException", e);
- }
- }
- }
-
- private void doXAResources(int status) {
- for (XAResource xaRes : new ArrayList<XAResource>(xaResources)) {
- if (status == Status.STATUS_COMMITTED) {
- try {
- xaRes.commit(null, true);
- } catch (XAException e) {
-
- }
- try {
- xaRes.end(null, XAResource.TMSUCCESS);
- } catch (XAException e) {
-
- }
- } else {
- try {
- xaRes.rollback(null);
- } catch (XAException e) {
-
- }
- try {
- xaRes.end(null, XAResource.TMFAIL);
- } catch (XAException e) {
- }
- }
- }
- xaResources.clear();
- }
- }
-}
-
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.ri.sp;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+
+import org.apache.openejb.spi.TransactionService;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+/**
+ * @org.apache.xbean.XBean element="pseudoTransactionService"
+ */
+public class PseudoTransactionService implements TransactionService, TransactionManager, TransactionSynchronizationRegistry {
+ private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.core.cmp");
+ private final ThreadLocal<MyTransaction> threadTransaction = new ThreadLocal<MyTransaction>();
+
+ public void init(Properties props) {
+ }
+
+ public TransactionManager getTransactionManager() {
+ return this;
+ }
+
+ public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
+ return this;
+ }
+
+ public int getStatus() {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ return Status.STATUS_NO_TRANSACTION;
+ }
+ return tx.getStatus();
+ }
+
+ public Transaction getTransaction() {
+ return threadTransaction.get();
+ }
+
+ public boolean getRollbackOnly() {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+ return tx.getRollbackOnly();
+ }
+
+ public void setRollbackOnly() {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+ tx.setRollbackOnly();
+ }
+
+ public void begin() throws NotSupportedException {
+ if (threadTransaction.get() != null) {
+ throw new NotSupportedException("A transaction is already active");
+ }
+
+ MyTransaction tx = new MyTransaction();
+ threadTransaction.set(tx);
+ }
+
+ public void commit() throws RollbackException {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+
+ try {
+ tx.commit();
+ } finally {
+ threadTransaction.set(null);
+ }
+ }
+
+
+ public void rollback() {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+
+ try {
+ tx.rollback();
+ } finally {
+ threadTransaction.set(null);
+ }
+ }
+
+ public Transaction suspend() {
+ return threadTransaction.get();
+ }
+
+ public void resume(Transaction tx) throws InvalidTransactionException {
+ if (tx == null) {
+ throw new InvalidTransactionException("Transaction is null");
+ }
+ if (!(tx instanceof MyTransaction)) {
+ throw new InvalidTransactionException("Unknown transaction type " + tx.getClass().getName());
+ }
+ MyTransaction myTransaction = (MyTransaction) tx;
+
+ if (threadTransaction.get() != null) {
+ throw new IllegalStateException("A transaction is already active");
+ }
+
+ int status = myTransaction.getStatus();
+ if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) {
+ throw new InvalidTransactionException("Expected transaction to be STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, but was " + status);
+ }
+
+ threadTransaction.set(myTransaction);
+ }
+
+ public Object getTransactionKey() {
+ return getTransaction();
+ }
+
+ public int getTransactionStatus() {
+ return getStatus();
+ }
+
+ public Object getResource(Object key) {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+
+ Object value = tx.getResource(key);
+ return value;
+ }
+
+ public void putResource(Object key, Object value) {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+
+ tx.putResource(key, value);
+ }
+
+ public void registerInterposedSynchronization(Synchronization synchronization) {
+ MyTransaction tx = threadTransaction.get();
+ if (tx == null) {
+ throw new IllegalStateException("No transaction active");
+ }
+
+ tx.registerInterposedSynchronization(synchronization);
+ }
+
+ public void setTransactionTimeout(int seconds) {
+ }
+
+ public class MyTransaction implements Transaction {
+ private final List<Synchronization> registeredSynchronizations = Collections.synchronizedList(new ArrayList<Synchronization>());
+ private final List<XAResource> xaResources = Collections.synchronizedList(new ArrayList<XAResource>());
+ private final Map<Object, Object> resources = new HashMap<Object,Object>();
+ private int status = Status.STATUS_ACTIVE;
+
+ public boolean delistResource(XAResource xaRes, int flag) {
+ xaResources.remove(xaRes);
+ return true;
+ }
+
+ public boolean enlistResource(XAResource xaRes) {
+ xaResources.add(xaRes);
+ return true;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void registerSynchronization(Synchronization synchronization) {
+ registeredSynchronizations.add(synchronization);
+ }
+
+ public void registerInterposedSynchronization(Synchronization synchronization) {
+ registeredSynchronizations.add(synchronization);
+ }
+
+ public boolean getRollbackOnly() {
+ return status == Status.STATUS_MARKED_ROLLBACK;
+ }
+
+ public void setRollbackOnly() {
+ status = Status.STATUS_MARKED_ROLLBACK;
+ }
+
+ public Object getResource(Object key) {
+ if (key == null) throw new NullPointerException("key is null");
+ return resources.get(key);
+ }
+
+ public void putResource(Object key, Object value) {
+ if (key == null) throw new NullPointerException("key is null");
+ if (value != null) {
+ resources.put(key, value);
+ } else {
+ resources.remove(key);
+ }
+ }
+
+ public void commit() throws RollbackException {
+ try {
+ if (status == Status.STATUS_MARKED_ROLLBACK) {
+ rollback();
+ throw new RollbackException();
+ }
+ try {
+ doBeforeCompletion();
+ } catch (Exception e) {
+ rollback();
+ throw (RollbackException) new RollbackException().initCause(e);
+ }
+ doXAResources(Status.STATUS_COMMITTED);
+ status = Status.STATUS_COMMITTED;
+ doAfterCompletion(Status.STATUS_COMMITTED);
+ } finally {
+ threadTransaction.set(null);
+ }
+ }
+
+ public void rollback() {
+ try {
+ doXAResources(Status.STATUS_ROLLEDBACK);
+ doAfterCompletion(Status.STATUS_ROLLEDBACK);
+ status = Status.STATUS_ROLLEDBACK;
+ registeredSynchronizations.clear();
+ } finally {
+ threadTransaction.set(null);
+ }
+ }
+
+ private void doBeforeCompletion() {
+ for (Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
+ sync.beforeCompletion();
+ }
+ }
+
+ private void doAfterCompletion(int status) {
+ for (Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
+ try {
+ sync.afterCompletion(status);
+ } catch (RuntimeException e) {
+ logger.warning("Synchronization afterCompletion threw a RuntimeException", e);
+ }
+ }
+ }
+
+ private void doXAResources(int status) {
+ for (XAResource xaRes : new ArrayList<XAResource>(xaResources)) {
+ if (status == Status.STATUS_COMMITTED) {
+ try {
+ xaRes.commit(null, true);
+ } catch (XAException e) {
+
+ }
+ try {
+ xaRes.end(null, XAResource.TMSUCCESS);
+ } catch (XAException e) {
+
+ }
+ } else {
+ try {
+ xaRes.rollback(null);
+ } catch (XAException e) {
+
+ }
+ try {
+ xaRes.end(null, XAResource.TMFAIL);
+ } catch (XAException e) {
+ }
+ }
+ }
+ xaResources.clear();
+ }
+ }
+}
+
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java Thu Aug 27 03:42:06 2009
@@ -1,21 +1,21 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.util;
-
-public interface Computable<K, V> {
- V compute(K key) throws InterruptedException;
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+public interface Computable<K, V> {
+ V compute(K key) throws InterruptedException;
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java Thu Aug 27 03:42:06 2009
@@ -1,59 +1,59 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.util;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-
-public class Memoizer<K, V> implements Computable<K, V> {
- private final ConcurrentMap<K, Future<V>> cache = new ConcurrentHashMap<K, Future<V>>();
-
- private final Computable<K, V> c;
-
- public Memoizer(Computable<K, V> c) {
- this.c = c;
- }
-
- public V compute(final K key) throws InterruptedException {
- while (true) {
- Future<V> future = cache.get(key);
- if (future == null) {
-
- Callable<V> eval = new Callable<V>() {
- public V call() throws Exception {
- return c.compute(key);
- }
- };
- FutureTask<V> futureTask = new FutureTask<V>(eval);
- future = cache.putIfAbsent(key, futureTask);
- if (future == null) {
- future = futureTask;
- futureTask.run();
- }
- }
- try {
- return future.get();
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- }
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+
+public class Memoizer<K, V> implements Computable<K, V> {
+ private final ConcurrentMap<K, Future<V>> cache = new ConcurrentHashMap<K, Future<V>>();
+
+ private final Computable<K, V> c;
+
+ public Memoizer(Computable<K, V> c) {
+ this.c = c;
+ }
+
+ public V compute(final K key) throws InterruptedException {
+ while (true) {
+ Future<V> future = cache.get(key);
+ if (future == null) {
+
+ Callable<V> eval = new Callable<V>() {
+ public V call() throws Exception {
+ return c.compute(key);
+ }
+ };
+ FutureTask<V> futureTask = new FutureTask<V>(eval);
+ future = cache.putIfAbsent(key, futureTask);
+ if (future == null) {
+ future = futureTask;
+ futureTask.run();
+ }
+ }
+ try {
+ return future.get();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PropertiesService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PropertiesService.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PropertiesService.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PropertiesService.java Thu Aug 27 03:42:06 2009
@@ -1,119 +1,119 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Manages properties so any property modifications are handled here.
- *
- * It lets us track the properties used and possibly remove some. They are all
- * scattered in many places and it's so hard to keep track of them.
- *
- * The class holds all OpenEJB properties and optionally can amend the
- * environment.
- *
- * The aim of this class is to establish one place to keep the properties and
- * eventually remove the need to set System properties to communicate between
- * parts and possibly yet lay out a foundation for setting them up in JNDI or
- * some other means
- *
- * TODO: Should this class be concerned with concurrency issues?
- *
- * @org.apache.xbean.XBean element="propertiesService"
- *
- * @version $Rev$ $Date$
- */
-public class PropertiesService {
- private Properties props = new Properties();
-
- /**
- * Should properties be passed on to the environment?
- */
- private boolean passOn = true;
-
- /**
- * Should the service query environment properties upon initialization?
- */
- private boolean queryEnvOnInit = true;
-
- public PropertiesService() {
- if (queryEnvOnInit) {
- props.putAll(System.getProperties());
- }
- }
-
- /**
- * Set value to a property. Optionally set System property via
- * {@link System#setProperty(String, String)}
- *
- * @param name
- * property name
- * @param value
- * property value
- * @return previous property value or null if the value hasn't been assigned
- * yet
- */
- public String setProperty(String name, String value) {
- if (passOn) {
- System.setProperty(name, value);
- }
- return (String) props.setProperty(name, value);
- }
-
- public String getProperty(String name) {
- return (String) props.get(name);
- }
-
- /**
- * ISSUE: It might be of help to differentiate between unavailable property
- * and boolean property set to false
- *
- * @param name
- * property name
- * @return true if property keyed by name is set; false otherwise
- */
- public boolean isSet(String name) {
- return props.containsKey(name);
- }
-
- public void putAll(Properties props) {
- props.putAll(props);
- }
-
- public Properties getProperties() {
- return props;
- }
-
- public boolean isPassOn() {
- return passOn;
- }
-
- public void setPassOn(boolean passOn) {
- this.passOn = passOn;
- }
-
- public boolean isQueryEnvOnInit() {
- return queryEnvOnInit;
- }
-
- public void setQueryEnvOnInit(boolean queryEnvOnInit) {
- this.queryEnvOnInit = queryEnvOnInit;
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages properties so any property modifications are handled here.
+ *
+ * It lets us track the properties used and possibly remove some. They are all
+ * scattered in many places and it's so hard to keep track of them.
+ *
+ * The class holds all OpenEJB properties and optionally can amend the
+ * environment.
+ *
+ * The aim of this class is to establish one place to keep the properties and
+ * eventually remove the need to set System properties to communicate between
+ * parts and possibly yet lay out a foundation for setting them up in JNDI or
+ * some other means
+ *
+ * TODO: Should this class be concerned with concurrency issues?
+ *
+ * @org.apache.xbean.XBean element="propertiesService"
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertiesService {
+ private Properties props = new Properties();
+
+ /**
+ * Should properties be passed on to the environment?
+ */
+ private boolean passOn = true;
+
+ /**
+ * Should the service query environment properties upon initialization?
+ */
+ private boolean queryEnvOnInit = true;
+
+ public PropertiesService() {
+ if (queryEnvOnInit) {
+ props.putAll(System.getProperties());
+ }
+ }
+
+ /**
+ * Set value to a property. Optionally set System property via
+ * {@link System#setProperty(String, String)}
+ *
+ * @param name
+ * property name
+ * @param value
+ * property value
+ * @return previous property value or null if the value hasn't been assigned
+ * yet
+ */
+ public String setProperty(String name, String value) {
+ if (passOn) {
+ System.setProperty(name, value);
+ }
+ return (String) props.setProperty(name, value);
+ }
+
+ public String getProperty(String name) {
+ return (String) props.get(name);
+ }
+
+ /**
+ * ISSUE: It might be of help to differentiate between unavailable property
+ * and boolean property set to false
+ *
+ * @param name
+ * property name
+ * @return true if property keyed by name is set; false otherwise
+ */
+ public boolean isSet(String name) {
+ return props.containsKey(name);
+ }
+
+ public void putAll(Properties props) {
+ props.putAll(props);
+ }
+
+ public Properties getProperties() {
+ return props;
+ }
+
+ public boolean isPassOn() {
+ return passOn;
+ }
+
+ public void setPassOn(boolean passOn) {
+ this.passOn = passOn;
+ }
+
+ public boolean isQueryEnvOnInit() {
+ return queryEnvOnInit;
+ }
+
+ public void setQueryEnvOnInit(boolean queryEnvOnInit) {
+ this.queryEnvOnInit = queryEnvOnInit;
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java Thu Aug 27 03:42:06 2009
@@ -1,62 +1,62 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.config;
-
-import org.apache.openejb.jee.AssemblyDescriptor;
-import org.apache.openejb.jee.EjbJar;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
-import javax.ejb.ApplicationException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class AnnotationDeployerTest {
-
- @Test
- /**
- * For http://issues.apache.org/jira/browse/OPENEJB-980
- */
- public void applicationExceptionInheritanceTest() throws Exception {
- EjbJar ejbJar = new EjbJar("test-classes");
- EjbModule ejbModule = new EjbModule(ejbJar);
- AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
- ejbModule = discvrAnnBeans.deploy(ejbModule);
-
- AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor();
- org.apache.openejb.jee.ApplicationException appEx =
- assemblyDescriptor.getApplicationException(BusinessException.class);
- assertThat(appEx, notNullValue());
- assertThat(appEx.getExceptionClass(), is(BusinessException.class.getName()));
- assertThat(appEx.getRollback(), is(true));
-
- appEx = assemblyDescriptor.getApplicationException(ValueRequiredException.class);
- assertThat(appEx, notNullValue());
- assertThat(appEx.getExceptionClass(), is(ValueRequiredException.class.getName()));
- assertThat(appEx.getRollback(), is(true));
- }
-
- @ApplicationException(rollback = true)
- public abstract class BusinessException extends Exception {
- }
-
- public class ValueRequiredException extends BusinessException {
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.config;
+
+import org.apache.openejb.jee.AssemblyDescriptor;
+import org.apache.openejb.jee.EjbJar;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+import org.junit.Test;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AnnotationDeployerTest {
+
+ @Test
+ /**
+ * For http://issues.apache.org/jira/browse/OPENEJB-980
+ */
+ public void applicationExceptionInheritanceTest() throws Exception {
+ EjbJar ejbJar = new EjbJar("test-classes");
+ EjbModule ejbModule = new EjbModule(ejbJar);
+ AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
+ ejbModule = discvrAnnBeans.deploy(ejbModule);
+
+ AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor();
+ org.apache.openejb.jee.ApplicationException appEx =
+ assemblyDescriptor.getApplicationException(BusinessException.class);
+ assertThat(appEx, notNullValue());
+ assertThat(appEx.getExceptionClass(), is(BusinessException.class.getName()));
+ assertThat(appEx.getRollback(), is(true));
+
+ appEx = assemblyDescriptor.getApplicationException(ValueRequiredException.class);
+ assertThat(appEx, notNullValue());
+ assertThat(appEx.getExceptionClass(), is(ValueRequiredException.class.getName()));
+ assertThat(appEx.getRollback(), is(true));
+ }
+
+ @ApplicationException(rollback = true)
+ public abstract class BusinessException extends Exception {
+ }
+
+ public class ValueRequiredException extends BusinessException {
+ }
+
+}