Come with me. "Cloud" End (c) Eclipselink+jboss implementing Multi-Tenant basic configuration

Source: Internet
Author: User
Tags jboss

This article mainly describes how to use Eclipselink in JBoss EAP6.2.

    • Development tools: JBoss Eap6.2+maven
    • Eclipselink version: 2.6.0
Add the module for Eclipselink
    • Using the pre-packaged integrated library: (ECLIPSELINK+JOBSS EAP6.2 integrated module)
    • After the download is done, unzip and use Maven to compile the extracted files:

    • View the Pom.xml files in them:
      Where the Properties node joins the Eclipselink version that you want to use, and modifies the version that eclipselink.version defines for itself:

As the original document:

<properties> <project. Build. sourceencoding>utf-8</project. Build. sourceencoding> <eclipselink. Version. 2. 3. Stable>2.3. 2</eclipselink. Version. 2. 3. Stable> <eclipselink. Version. 2. 3. Milestone>2.3. 3-m3</eclipselink. Version. 2. 3. Milestone> <eclipselink. Version. 2. 4. Milestone>2.4. 0</eclipselink. Version. 2. 4. Milestone> <eclipselink. Version>${eclipselink. Version. 2. 4. Milestone}</eclipselink. Version> <jboss-version>7.1. 1. Final</jboss-version> <as7module. Srcdir>${project. Basedir}/src/main/as7module</as7module. Srcdir> <as7module. Destdir>${project. Build. Directory}/as7module</as7module. Destdir> <eclipselink_jar_name>eclipselink-${eclipselink. Version}. Jar</ECLIPSELINK_JAR_NAME> <integration_jar_name>${project. Artifactid}-${project. Version}.${project. Packaging}</integration_jar_name> </properties>

After modification:

<properties> <project. Build. sourceencoding>utf-8</project. Build. sourceencoding> <eclipselink. Version. 2. 3. Stable>2.3. 2</eclipselink. Version. 2. 3. Stable> <eclipselink. Version. 2. 3. Milestone>2.3. 3-m3</eclipselink. Version. 2. 3. Milestone> <eclipselink. Version. 2. 4. Milestone>2.4. 0</eclipselink. Version. 2. 4. Milestone> <eclipselink. Version. 2. 6. Milestone>2.6. 0</eclipselink. Version. 2. 6. Milestone> <eclipselink. Version>${eclipselink. Version. 2. 6. Milestone}</eclipselink. Version> <jboss-version>7.1. 1. Final</jboss-version> <as7module. Srcdir>${project. Basedir}/src/main/as7module</as7module. Srcdir> <as7module. Destdir>${project. Build. Directory}/as7module</as7module. Destdir> <eclipselink_jar_name>eclipselink-${eclipselink. Version}. Jar</ECLIPSELINK_JAR_NAME> <integration_jar_name>${project. Artifactid}-${project. Version}.${project. Packaging}</integration_jar_name> </properties>
    • Use the command window to go to this directory and execute the command:
install
    • After running, generate the target directory as follows:

    • Copy the Target/as7module directory under ID and org two folders to the $jboss_home/modules/system/layers/base directory (if the Org directory already exists, merge)

    • Start JBoss, execute

$JBOSS_HOME/bin/jboss-cli.bat --connect
    • Execute the following command:
/system-property=eclipselink.archive.factory:add(value=id.au.ringerc.as7.eclipselinkintegration.JBossArchiveFactoryImpl)
    • After execution, you will find the following configuration in the Standalone.xml file:
<system-properties>        <property name="eclipselink.archive.factory" value="id.au.ringerc.as7.eclipselinkintegration.JBossArchiveFactoryImpl"/>    </system-properties>
    • You can set up Eclipselink.target-server execution together at this time:
 /system-property=eclipselink.target-server:add(value=JBoss)
Set Eclipselink.target-server
    • Delete the original hibernate configuration in Persistence.xml, add the following provider and property
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider><property name="eclipselink.target-server" value="JBoss"/>
Set up entity Auto-scan
    • If you do not make any configuration by default, you need to list all the entities in your system in Persistence.xml, as follows:
< class>mtsample. Hotel. model. renthistory </class>< class>mtsample. Hotel. model. hotelguest </class>< class>mtsample. Hotel. model. Tenant </class>< class>mtsample. Hotel. model.  the </class>< class>mtsample. Hotel. model. Category </class>< class>mtsample. Hotel. model. Hoteladmin </class>......
    • The entity can be automatically scanned when the first step is set.
Set a static weave (static weaving) so that the entity supports inheritance.
    • When you need entity inheritance, this is a very common feature, there will be some common properties in the entity, such as ID, or timestamp, but when using eclipselink entity inheritance, for some reason can not be dynamically woven at runtime, need to configure at compile time static weaving.
    • To be exact, how to set up static weaving depends on the widget you use, and if you're using Ant,eclipselink to provide an ant task, Org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask. If you are using MAVEN, you can use Maven's static weaving plug-in, This plugin does not belong to the Eclipselink project.
<build>    <plugins>        <plugin>            <groupId>Au.com.alderaan</groupId>            <artifactid>Eclipselink-staticweave-maven-plugin</artifactid>            <version>1.0.3</version>            <executions>                <execution>                    <phase>Process-classes</phase>                    <goals>                        <goal>Weave</goal>                    </goals>                    <configuration>                        <persistencexmllocation>Meta-inf/persistence.xml</persistencexmllocation>                        <logLevel>FINE</logLevel>                    </configuration>                </Execution>            </executions>            <dependencies>                <dependency>                    <groupId>Org.eclipse.persistence</groupId>                    <artifactid>Eclipselink</artifactid>                    <version>2.6.0</version>                </Dependency>            </dependencies>        </plugin>    </plugins></Build>
    • You also need to add the following attributes to the Persistence.xml file:
<propertyname="eclipselink.weaving" value="static"/>
    • Here you can use Eclipselink to develop your enterprise multi-tenant project.
The translation of this article refers to:

Https://developer.jboss.org/wiki/HowToUseEclipseLinkWithAS7?_sscc=t

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Come with me. "Cloud" End (c) Eclipselink+jboss implementing Multi-Tenant basic configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.