cli variables
by Alexey Loubyansky
There is this issue to provide CLI preferences
https://issues.jboss.org/browse/WFLY-1063. Here I'd like to address
mainly this part
"prod-db = /subsystem=jadada/database=jadada/
so you could call prod-db:read-resource"
I'd like to get some opinion on the way it's gonna be implemented (and
what I've done so far on a local branch).
So, to address that I introduced variables. A variable starts with a $,
e.g. $prod_db. (Using simply prod_db is not a good idea since it might
conflict with actual parts of the paths, names, etc)
Variables can be introduced with
[disconnected /] set prod_db=/subsystem=datasources/data-source=ExampleDS
Read with
[standalone@localhost:9990 /] echo prod_db
/subsystem=datasources/data-source=ExampleDS
And unset with
[standalone@localhost:9990 /] unset prod_db
'echo' without parameters will list all the variables and their values,
'set prod_db=' will have the same effect as 'unset prod_db',
set/echo/unset will work with and w/o '$' prefix, tab-completion works
everywhere.
The variables may appear in:
- operation request addresses, e.g. $prod_db/statistics=jdbc:read-resource;
- operation names, e.g. $prod_db:$op(include-runtime=true);
- operation parameter names and values, e.g.
$prod_db:$op($param=$param_value);
- the same for commands.
Tab-completion helps complete the names as long as you type in '$' and
then the rest of the line after the variable as usual.
Variables added during the session are not persisted anywhere. But I've
added .jbossclirc file. This file can be located in the current
directory, wildfly home bin directory or specified with a system
property. The content of the file is usual CLI commands and/or
operations. So, the variables could be initialized there. This file, if
located, will be executed before the CLI session (interactive or not)
starts (but also after the system properties specified with --properties
are set).
As a side effect, '$' is now a special character and will have to be
escaped. Otherwise the CLI might complain about an unresolved variable.
So, this could potentially cause problems for existing scripts using $.
Note, most of this replacement stuff can already be done with system
properties using ${xxx} format (and btw scripts using '$' as in '${xxx}'
won't be affected, of course).
And for now I've made variable names follow the rules for Java identifiers.
Any remarks, objections or suggestions?
Thanks,
Alexey
10 years, 11 months
Help with ClusterJPA & OpenJPA
by Mohammad Alkahtani
I'm trying to do J2EE version of this tutorial which J2SE
http://www.clusterdb.com/mysql-cluster/using-clusterjpa-part-of-mysql-clu...
I installed OpenJPA as module in JBoss add the MySQL JDBC datasource
to JBoss AS 7 then I run my application with persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="SQLTPU" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>java:/mcube/DefaultDS</jta-data-source>
<class>org.ksu.SQLT.entities.Employee</class>
<class>org.ksu.SQLT.entities.Department</class>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.apache.openjpa" />
<!-- IMPORTANT PROPERTIES -->
<property name="openjpa.DynamicEnhancementAgent" value="false"/>
<property name="openjpa.RuntimeUnenhancedClasses"
value="supported" />
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
<!-- <property name="openjpa.jdbc.DBDictionary" value="mysql" /> !-->
<property name="openjpa.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL"
value="jdbc:mysql://192.168.1.13:3306/clusterdb" />
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="Password" />
<property name="openjpa.BrokerFactory"
value="com.mysql.clusterj.openjpa.NdbOpenJPABrokerFactory" />
<property name="openjpa.jdbc.DBDictionary" value="TableType=ndbcluster" />
<property name="openjpa.ndb.connectString" value="192.168.1.13:1186" />
<property name="openjpa.ndb.database" value="clusterdb" />
</properties>
</persistence-unit>
</persistence>
I add the .jar files ClusterJPA, ClusterJ and ClusterAPI to the
project library folder in NetBeans. the application deployed but dose
not create the tables in the database
11 years