forked from spagop/quickstart
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- made some minor modifications to show how to connect to a secured m…
…gmt port - created an example for a xa-datasource and howto create xa-datasource-properties elements.
- Loading branch information
Showing
5 changed files
with
205 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.jboss.as.quickstarts</groupId> | ||
<artifactId>mgmt-create-xa-ds</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
<name>JBoss AS Quickstarts: Create a XA Datasource through the Mgmt API</name> | ||
|
||
<url>http://jboss.org/jbossas</url> | ||
<licenses> | ||
<license> | ||
<name>GNU Lesser General Public License</name> | ||
<url>http://www.gnu.org/copyleft/lesser.html</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<!-- Explicitly declaring the source encoding eliminates the following | ||
message: --> | ||
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered | ||
resources, i.e. build is platform dependent! --> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- Define the version of JBoss' Java EE 6 APIs we want to use --> | ||
<!-- JBoss distributes a complete set of Java EE 6 APIs including a Bill | ||
of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection) | ||
of artifacts. We use this here so that we always get the correct versions | ||
of artifacts. Here we use the jboss-javaee-6.0 stack (you can read this as | ||
the JBoss stack of the Java EE 6 APIs). You can actually use this stack with | ||
any version of JBoss AS that implements Java EE 6, not just JBoss AS 7! --> | ||
<dependency> | ||
<groupId>org.jboss.spec</groupId> | ||
<artifactId>jboss-javaee-6.0</artifactId> | ||
<version>3.0.0.Beta1</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.as</groupId> | ||
<artifactId>jboss-as-controller-client</artifactId> | ||
<version>7.1.0.Beta1b</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.as</groupId> | ||
<artifactId>jboss-as-controller</artifactId> | ||
<version>7.1.0.Beta1b</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!-- Set the name of the war, used as the context root when the app is | ||
deployed --> | ||
<finalName>mgmt-create-xa-ds</finalName> | ||
<plugins> | ||
<!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation | ||
processors --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.1</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.2.1</version> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>java</goal> | ||
</goals> | ||
<configuration> | ||
<mainClass>org.jboss.as.quickstarts.mgmt.Client</mainClass> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
75 changes: 75 additions & 0 deletions
75
mgmt-create-xa-ds/src/main/java/org/jboss/as/quickstarts/mgmt/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.jboss.as.quickstarts.mgmt; | ||
|
||
import org.jboss.as.controller.client.ModelControllerClient; | ||
import org.jboss.dmr.ModelNode; | ||
|
||
import java.net.InetAddress; | ||
|
||
/** | ||
* Red Hat GmbH - Global Professional Services (GPS) | ||
* <p/> | ||
* Author: <a href="mailto:jhoffmann@redhat.com">Juergen Hoffmann</a> | ||
* Date: 13.02.12 | ||
* Time: 09:51 | ||
*/ | ||
public class Client | ||
{ | ||
public static void main(String[] args) throws Exception | ||
{ | ||
ModelControllerClient client = ModelControllerClient.Factory.create( | ||
InetAddress.getByName("127.0.0.1"), 9999); | ||
|
||
try{ | ||
String dsname = "REPLACE_WITH_PROPERTY"; | ||
ModelNode op = new ModelNode(); | ||
op.get("operation").set("add"); | ||
|
||
op.get("address").add("subsystem", "datasources").add("xa-data-source", dsname); | ||
|
||
op.get("jndi-name").set("java:jboss/datasources/" + "XA" + dsname); | ||
op.get("xa-datasource-class").set("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"); | ||
op.get("driver-name").set("mysql"); | ||
op.get("use-java-context").set("true"); | ||
op.get("pool-name").set("TestXADS"); | ||
op.get("xa-resource-timeout").set(3600); | ||
op.get("jta").set(true); | ||
|
||
op.get("max-pool-size").set(10); | ||
op.get("min-pool-size").set(5); | ||
|
||
ModelNode result = client.execute(op); | ||
|
||
System.out.println(result.toString()); | ||
|
||
op = new ModelNode(); | ||
op.get("operation").set("add"); | ||
op.get("address").add("subsystem","datasources").add("xa-data-source", dsname).add("xa-datasource-properties", "URL"); | ||
op.get("value").set("jdbc:mysql://localhost/demo"); | ||
|
||
result = client.execute(op); | ||
|
||
System.out.println(result.toString()); | ||
|
||
op = new ModelNode(); | ||
op.get("operation").set("add"); | ||
op.get("address").add("subsystem","datasources").add("xa-data-source", dsname).add("xa-datasource-properties", "User"); | ||
op.get("value").set("demo"); | ||
|
||
result = client.execute(op); | ||
|
||
System.out.println(result.toString()); | ||
|
||
op = new ModelNode(); | ||
op.get("operation").set("add"); | ||
op.get("address").add("subsystem","datasources").add("xa-data-source", dsname).add("xa-datasource-properties", "Password"); | ||
op.get("value").set("demo"); | ||
|
||
result = client.execute(op); | ||
|
||
System.out.println(result.toString()); | ||
} | ||
finally { | ||
client.close(); | ||
} | ||
} | ||
} |