[jboss-cvs] JBossAS SVN: r111013 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/common and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 23 21:23:03 EDT 2011
Author: jeff.zhang
Date: 2011-03-23 21:23:02 -0400 (Wed, 23 Mar 2011)
New Revision: 111013
Added:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagementRepository.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml
projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml
Log:
[JBJCA-534] Add DataSource to ManagementRepository
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/DataSource.java 2011-03-24 01:23:02 UTC (rev 111013)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.api.management;
+
+import org.jboss.jca.core.api.connectionmanager.pool.Pool;
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Represents a datasource instance
+ *
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a>
+ */
+public class DataSource
+{
+
+ /** xa datasource or not */
+ private boolean xa;
+
+ /** jndi name */
+ private String jndiName;
+
+ /** The pool instance */
+ private WeakReference<Pool> pool;
+
+ /** The pool configuration instance */
+ private WeakReference<PoolConfiguration> poolConfiguration;
+
+ /**
+ * Constructor
+ *
+ * @param xa datasource is xa or not
+ * @param jndiName jndi name
+ */
+ public DataSource(boolean xa, String jndiName)
+ {
+ this.xa = xa;
+ this.jndiName = jndiName;
+ }
+
+ /**
+ * xa datasource
+ *
+ * @return true if it xa datasource
+ */
+ public boolean isXA()
+ {
+ return xa;
+ }
+
+ /**
+ * Get the pool instance.
+ *
+ * Note, that the value may be <code>null</code> if the pool was
+ * undeployed and this object wasn't cleared up correctly.
+ * @return The instance
+ */
+ public Pool getPool()
+ {
+ if (pool == null)
+ return null;
+
+ return pool.get();
+ }
+
+ /**
+ * Set the pool
+ * @param p The pool
+ */
+ public void setPool(Pool p)
+ {
+ this.pool = new WeakReference<Pool>(p);
+ }
+
+ /**
+ * Get the pool configuration instance.
+ *
+ * Note, that the value may be <code>null</code> if the pool configuration was
+ * undeployed and this object wasn't cleared up correctly.
+ * @return The instance
+ */
+ public PoolConfiguration getPoolConfiguration()
+ {
+ if (poolConfiguration == null)
+ return null;
+
+ return poolConfiguration.get();
+ }
+
+ /**
+ * Set the pool configuration
+ * @param pc The pool configuration
+ */
+ public void setPoolConfiguration(PoolConfiguration pc)
+ {
+ this.poolConfiguration = new WeakReference<PoolConfiguration>(pc);
+ }
+
+ /**
+ * Get the jndiName.
+ *
+ * @return the jndiName.
+ */
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ /**
+ * String representation
+ * @return The string
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("DataSource@").append(Integer.toHexString(System.identityHashCode(this)));
+ sb.append(" xa=").append(isXA());
+ sb.append(" jndiName=").append(getJndiName());
+ sb.append(" pool=").append(getPool());
+ sb.append(" poolconfiguration=").append(getPoolConfiguration());
+ sb.append("]");
+
+ return sb.toString();
+ }
+}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagementRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagementRepository.java 2011-03-23 21:40:34 UTC (rev 111012)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagementRepository.java 2011-03-24 01:23:02 UTC (rev 111013)
@@ -30,18 +30,23 @@
* The management repository
*
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a>
*/
public class ManagementRepository
{
/** Resource adapter archives */
private List<Connector> connectors;
+ /** data sources */
+ private List<DataSource> datasources;
+
/**
* Constructor
*/
public ManagementRepository()
{
this.connectors = Collections.synchronizedList(new ArrayList<Connector>(1));
+ this.datasources = Collections.synchronizedList(new ArrayList<DataSource>(1));
}
/**
@@ -54,6 +59,15 @@
}
/**
+ * Get the list of connectors
+ * @return The value
+ */
+ public List<DataSource> getDataSources()
+ {
+ return datasources;
+ }
+
+ /**
* String representation
* @return The string
*/
@@ -64,6 +78,7 @@
sb.append("ManagementRepository@").append(Integer.toHexString(System.identityHashCode(this)));
sb.append("[connectors=").append(connectors);
+ sb.append(" datasources=").append(datasources);
sb.append("]");
return sb.toString();
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2011-03-23 21:40:34 UTC (rev 111012)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java 2011-03-24 01:23:02 UTC (rev 111013)
@@ -38,6 +38,7 @@
import org.jboss.jca.common.metadata.merge.Merger;
import org.jboss.jca.common.metadata.ra.common.ConfigPropertyImpl;
import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+import org.jboss.jca.core.api.management.ManagementRepository;
import org.jboss.jca.core.connectionmanager.ConnectionManager;
import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
@@ -84,6 +85,9 @@
/** xaResourceRecoveryRegistry */
protected XAResourceRecoveryRegistry xaResourceRecoveryRegistry;
+ /** The ManagementRepository */
+ private ManagementRepository managementRepository = null;
+
/**
* Create a new AbstractDsDeployer.
* @param log The logger
@@ -130,8 +134,28 @@
{
return mdr;
}
+
+ /**
+ * Get the managementRepository.
+ *
+ * @return the managementRepository.
+ */
+ public ManagementRepository getManagementRepository()
+ {
+ return managementRepository;
+ }
/**
+ * Set the managementRepository.
+ *
+ * @param managementRepository The managementRepository to set.
+ */
+ public void setManagementRepository(ManagementRepository managementRepository)
+ {
+ this.managementRepository = managementRepository;
+ }
+
+ /**
*
* create objects and inject value for this depployment. it is a general method returning a {@link CommonDeployment}
* to be used to exchange objects needed to real injection in the container
@@ -318,6 +342,14 @@
allocationRetryWaitMillis = ds.getTimeOut().getAllocationRetryWaitMillis();
}
+ //register data sources
+ org.jboss.jca.core.api.management.DataSource mgtDs =
+ new org.jboss.jca.core.api.management.DataSource(false, jndiName);
+ mgtDs.setPoolConfiguration(pc);
+ mgtDs.setPool(pool);
+ log.debugf("Adding management datasource: %s", mgtDs);
+ getManagementRepository().getDataSources().add(mgtDs);
+
// Select the correct connection manager
TransactionSupportLevel tsl = TransactionSupportLevel.LocalTransaction;
ConnectionManagerFactory cmf = new ConnectionManagerFactory();
@@ -462,6 +494,14 @@
padXid = ds.getXaPool().isPadXid();
}
+ //register data sources
+ org.jboss.jca.core.api.management.DataSource mgtDs =
+ new org.jboss.jca.core.api.management.DataSource(true, jndiName);
+ mgtDs.setPoolConfiguration(pc);
+ mgtDs.setPool(pool);
+ log.debugf("Adding management datasource: %s", mgtDs);
+ getManagementRepository().getDataSources().add(mgtDs);
+
// Select the correct connection manager
TransactionSupportLevel tsl = TransactionSupportLevel.XATransaction;
ConnectionManagerFactory cmf = new ConnectionManagerFactory();
Modified: projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml 2011-03-23 21:40:34 UTC (rev 111012)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml 2011-03-24 01:23:02 UTC (rev 111013)
@@ -8,6 +8,7 @@
<property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
<property name="MetadataRepository"><inject bean="MDR"/></property>
<property name="Kernel"><inject bean="Kernel"/></property>
+ <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
</bean>
</deployment>
Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml 2011-03-23 21:40:34 UTC (rev 111012)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml 2011-03-24 01:23:02 UTC (rev 111013)
@@ -9,6 +9,7 @@
<property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
<property name="MetadataRepository"><inject bean="MDR"/></property>
<property name="Kernel"><inject bean="Kernel"/></property>
+ <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
</bean>
</deployment>
More information about the jboss-cvs-commits
mailing list