[jboss-cvs] JBossAS SVN: r59443 - in trunk/ejb3/src/main/org/jboss: ejb3/session and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 9 13:00:50 EST 2007
Author: bstansberry at jboss.com
Date: 2007-01-09 13:00:48 -0500 (Tue, 09 Jan 2007)
New Revision: 59443
Modified:
trunk/ejb3/src/main/org/jboss/annotation/ejb/Clustered.java
trunk/ejb3/src/main/org/jboss/annotation/ejb/ClusteredImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
Log:
[EJBTHREE-424] Add check of the jboss.partition.name to the @Clustered annotation
Modified: trunk/ejb3/src/main/org/jboss/annotation/ejb/Clustered.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/Clustered.java 2007-01-09 17:58:17 UTC (rev 59442)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/Clustered.java 2007-01-09 18:00:48 UTC (rev 59443)
@@ -40,5 +40,5 @@
{
Class loadBalancePolicy() default LoadBalancePolicy.class;
- String partition() default "DefaultPartition";
+ String partition() default "${jboss.partition.name:DefaultPartition}";;
}
Modified: trunk/ejb3/src/main/org/jboss/annotation/ejb/ClusteredImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/ClusteredImpl.java 2007-01-09 17:58:17 UTC (rev 59442)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/ClusteredImpl.java 2007-01-09 18:00:48 UTC (rev 59443)
@@ -32,7 +32,7 @@
public class ClusteredImpl implements Clustered
{
private Class loadBalancePolicy = LoadBalancePolicy.class;
- private String partition = "DefaultPartition";
+ private String partition = null;
public Class loadBalancePolicy()
Modified: trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-01-09 17:58:17 UTC (rev 59442)
+++ trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-01-09 18:00:48 UTC (rev 59443)
@@ -32,6 +32,7 @@
import org.jboss.ejb3.EJBContainer;
import org.jboss.ejb3.ProxyFactory;
import org.jboss.logging.Logger;
+import org.jboss.util.StringPropertyReplacer;
import org.jboss.ejb3.proxy.EJBMetaDataImpl;
import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
@@ -104,5 +105,39 @@
return metadata;
}
+
+ /**
+ * Performs a system property substitution if the given value conforms to the
+ * "${property.name}" or "${property.name:defaultvalue}" patterns; otherwise just
+ * returns <code>value</value>.
+ *
+ * TODO Put this in a utility somewhere; this is just the common parent of
+ * the places that currently use it.
+ *
+ * @param value a String that may represent a system property.
+ *
+ * @return the value of the given system property, or the provided default value
+ * if there was no system property matching the given string, or
+ * <code>value</code> itself if it didn't encode a system property name.
+ */
+ protected String substituteSystemProperty(String value)
+ {
+ try
+ {
+ String replacedValue = StringPropertyReplacer.replaceProperties(value);
+ if (value != replacedValue)
+ {
+ log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
+ value = replacedValue;
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to replace @Clustered partition attribute " + value +
+ ". Caused by " + e.getClass() + " " + e.getMessage());
+ }
+
+ return value;
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-01-09 17:58:17 UTC (rev 59442)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-01-09 18:00:48 UTC (rev 59443)
@@ -86,7 +86,9 @@
locator = new InvokerLocator(clientBindUrl);
Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation. Cannot deploy.");
- String partitionName = clustered.partition();
+ // Partition name may be ${jboss.partition.name:DefaultPartition}
+ // so do a system property substitution
+ String partitionName = substituteSystemProperty(clustered.partition());
proxyFamilyName = container.getEjbName() + locator.getProtocol() + partitionName;
HAPartition partition = (HAPartition) container.getInitialContext().lookup("/HAPartition/" + partitionName);
hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2007-01-09 17:58:17 UTC (rev 59442)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2007-01-09 18:00:48 UTC (rev 59443)
@@ -79,7 +79,9 @@
locator = new InvokerLocator(clientBindUrl);
Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation. Cannot deploy.");
- String partitionName = clustered.partition();
+ // Partition name may be ${jboss.partition.name:DefaultPartition}
+ // so do a system property substitution
+ String partitionName = substituteSystemProperty(clustered.partition());
proxyFamilyName = container.getEjbName() + locator.getProtocol() + partitionName;
HAPartition partition = (HAPartition) container.getInitialContext().lookup("/HAPartition/" + partitionName);
hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
More information about the jboss-cvs-commits
mailing list