Dashboard > Penrose Community > ... > Wiki > Sample Demo with MySQL
Sample Demo with MySQL
Added by Divyaman Singh Rawat, last edited by Jim Yang on Mar 09, 2006  (view change)
Labels: 
(None)


Here is a sample demo of Penrose with a MySQL database as the backend. The demo uses the example.schema file and the sample database provided here. You have to call the MySQL database 'sales'. If you come across any problems with reading/writing data from/to the database, please post a message in the discussiong board.
I am attaching the configuration files you'll need to run this demo.

#This is connections.xml

<?xml version="1.0" encoding="UTF-8"?>

<connections>
<connection name="MySQL_sales">
<adapter-name>JDBC</adapter-name>
<parameter>
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</parameter>
<parameter>
<param-name>password</param-name>
<param-value>penrose</param-value>
</parameter>
<parameter>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost:3306/sales?autoReconnect=true</param-value>
</parameter>
<parameter>
<param-name>user</param-name>
<param-value>penrose</param-value>
</parameter>
</connection>
</connections>

#This is mapping.xml

<?xml version="1.0" encoding="UTF-8"?>

<mapping>
<entry dn="ou=Sales">
<oc>organizationalUnit</oc>
<oc>top</oc>
<at name="ou" rdn="true">
<constant>Sales</constant>
</at>
</entry>
<entry dn="dc=Categories,ou=Sales">
<oc>dcObject</oc>
<oc>top</oc>
<at name="dc" rdn="true">
<constant>Categories</constant>
</at>
</entry>
<entry dn="cn=...,dc=Categories,ou=Sales">
<oc>category</oc>
<oc>top</oc>
<at name="categoryId">
<variable>categories.id</variable>
</at>
<at name="cn" rdn="true">
<variable>categories.name</variable>
</at>
<at name="description">
<variable>categories.description</variable>
</at>
<source name="categories">
<source-name>categories</source-name>
<field name="description">
<variable>description</variable>
</field>
<field name="id">
<variable>categoryId</variable>
</field>
<field name="name">
<variable>cn</variable>
</field>
</source>
</entry>
<entry dn="cn=...,cn=...,dc=Categories,ou=Sales">
<oc>product</oc>
<oc>top</oc>
<at name="categoryId">
<variable>products.categoryId</variable>
</at>
<at name="cn" rdn="true">
<variable>products.name</variable>
</at>
<at name="price">
<variable>products.price</variable>
</at>
<at name="productId">
<variable>products.id</variable>
</at>
<source name="products">
<source-name>products</source-name>
<field name="categoryId">
<variable>categoryId</variable>
</field>
<field name="id">
<variable>productId</variable>
</field>
<field name="name">
<variable>cn</variable>
</field>
<field name="price">
<variable>price</variable>
</field>
</source>
<relationship>
<expression>categories.id = products.categoryId</expression>
</relationship>
</entry>
<entry dn="dc=Customers,ou=Sales">
<oc>dcObject</oc>
<oc>top</oc>
<at name="dc" rdn="true">
<constant>Customers</constant>
</at>
</entry>
<entry dn="cn=...,dc=Customers,ou=Sales">
<oc>customer</oc>
<oc>top</oc>
<at name="cn" rdn="true">
<variable>customer_emails.email</variable>
</at>
<at name="customerId">
<variable>customer_emails.username</variable>
</at>
<at name="email">
<variable>customer_emails.email</variable>
</at>
<source name="customer_emails">
<source-name>customer_emails</source-name>
<field name="email">
<variable>email</variable>
</field>
<field name="username">
<variable>customerId</variable>
</field>
</source>
</entry>
<entry dn="orderId=...,cn=...,dc=Customers,ou=Sales">
<oc>order</oc>
<oc>top</oc>
<at name="customerId">
<variable>orders.username</variable>
</at>
<at name="date">
<variable>orders.orderDate</variable>
</at>
<at name="orderId" rdn="true">
<variable>orders.id</variable>
</at>
<source name="orders">
<source-name>orders</source-name>
<field name="id">
<variable>orderId</variable>
</field>
<field name="orderDate">
<variable>date</variable>
</field>
<field name="username">
<variable>customerId</variable>
</field>
</source>
<relationship>
<expression>customer_emails.username = orders.username</expression>
</relationship>
</entry>
<entry dn="cn=...,orderId=...,cn=...,dc=Customers,ou=Sales">
<oc>orderDetail</oc>
<oc>product</oc>
<oc>top</oc>
<at name="categoryId">
<variable>products.categoryId</variable>
</at>
<at name="cn" rdn="true">
<variable>products.name</variable>
</at>
<at name="description">
<variable>order_details.quantity</variable>
</at>
<at name="orderId">
<variable>order_details.orderId</variable>
</at>
<at name="price">
<variable>products.price</variable>
</at>
<at name="productId">
<variable>products.id</variable>
</at>
<source name="order_details">
<source-name>order_details</source-name>
<field name="orderId">
<variable>orderId</variable>
</field>
<field name="quantity">
<variable>description</variable>
</field>
</source>
<source name="products">
<source-name>products</source-name>
<field name="categoryId">
<variable>categoryId</variable>
</field>
<field name="id">
<variable>productId</variable>
</field>
<field name="name">
<variable>cn</variable>
</field>
<field name="price">
<variable>price</variable>
</field>
</source>
<relationship>
<expression>order_details.orderId = orders.id</expression>
</relationship>
<relationship>
<expression>order_details.productId = products.id</expression>
</relationship>
</entry>
</mapping>

#This is modules.xml

<?xml version="1.0" encoding="UTF-8"?>

<modules/>

#This is server.xml

<?xml version="1.0" encoding="UTF-8"?>

<server>
<service name="JMX Service">
<service-class>org.safehaus.penrose.management.PenroseJMXService</service-class>
</service>
<service name="LDAP Service">
<service-class>org.safehaus.penrose.ldap.PenroseLDAPService</service-class>
</service>
<schema name="autofs" path="schema/autofs.schema"/>
<schema name="corba" path="schema/corba.schema"/>
<schema name="core" path="schema/core.schema"/>
<schema name="cosine" path="schema/cosine.schema"/>
<schema name="apache" path="schema/apache.schema"/>
<schema name="collective" path="schema/collective.schema"/>
<schema name="inetorgperson" path="schema/inetorgperson.schema"/>
<schema name="java" path="schema/java.schema"/>
<schema name="krb5kdc" path="schema/krb5kdc.schema"/>
<schema name="nis" path="schema/nis.schema"/>
<schema name="system" path="schema/system.schema"/>
<schema name="apachedns" path="schema/apachedns.schema"/>
<schema name="example" path="schema/ext/example.schema"/>
<interpreter>
<interpreter-class>org.safehaus.penrose.interpreter.DefaultInterpreter</interpreter-class>
</interpreter>
<entry-cache/>
<source-cache/>
<session-handler/>
<engine/>
<connector/>
<adapter name="JDBC">
<adapter-class>org.safehaus.penrose.connector.JDBCAdapter</adapter-class>
</adapter>
<adapter name="JNDI">
<adapter-class>org.safehaus.penrose.connector.JNDIAdapter</adapter-class>
</adapter>
<partition name="DEFAULT" path="conf"/>
<root>
<root-dn>uid=admin,ou=system</root-dn>
<root-password>secret</root-password>
</root>
</server>

#This is sources.xml

<?xml version="1.0" encoding="UTF-8"?>

<sources>
<source name="categories">
<connection-name>MySQL_sales</connection-name>
<field name="description" type="LONGVARCHAR"/>
<field name="id" primaryKey="true" type="INTEGER"/>
<field name="name"/>
<parameter>
<param-name>tableName</param-name>
<param-value>categories</param-value>
</parameter>
</source>
<source name="customer_emails">
<connection-name>MySQL_sales</connection-name>
<field name="email" primaryKey="true"/>
<field name="username"/>
<parameter>
<param-name>tableName</param-name>
<param-value>customer_emails</param-value>
</parameter>
</source>
<source name="order_details">
<connection-name>MySQL_sales</connection-name>
<field name="orderId" primaryKey="true" type="INTEGER"/>
<field name="price" type="DOUBLE"/>
<field name="productId" primaryKey="true" type="INTEGER"/>
<field name="quantity" type="INTEGER"/>
<parameter>
<param-name>tableName</param-name>
<param-value>order_details</param-value>
</parameter>
</source>
<source name="orders">
<connection-name>MySQL_sales</connection-name>
<field name="id" primaryKey="true" type="INTEGER"/>
<field name="orderDate" type="TIMESTAMP"/>
<field name="username"/>
<parameter>
<param-name>tableName</param-name>
<param-value>orders</param-value>
</parameter>
</source>
<source name="products">
<connection-name>MySQL_sales</connection-name>
<field name="categoryId" type="INTEGER"/>
<field name="id" primaryKey="true" type="INTEGER"/>
<field name="name"/>
<field name="price" type="DOUBLE"/>
<parameter>
<param-name>tableName</param-name>
<param-value>products</param-value>
</parameter>
</source>
</sources>

#This is wrapper.conf

#********************************************************************

  1. Wrapper Properties
    #********************************************************************
  2. Java Application
    wrapper.java.command=java
  1. Java Main class. This class must implement the WrapperListener interface
  2. or guarantee that the WrapperManager class is initialized. Helper
  3. classes are provided to do this for you. See the Integration section
  4. of the documentation for details.
    wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
  1. Java Classpath (include wrapper.jar) Add class path elements as
  2. needed starting from 1
    wrapper.java.classpath.1=../lib/apacheds-main-0.9.3-SNAPSHOT.jar
    wrapper.java.classpath.2=../lib/bcprov-jdk14-125.jar
    wrapper.java.classpath.3=../lib/bsh-2.0b4.jar
    wrapper.java.classpath.4=../lib/commons-beanutils-1.6.jar
    wrapper.java.classpath.5=../lib/commons-dbcp-1.2.jar
    wrapper.java.classpath.6=../lib/commons-digester-1.5.jar
    wrapper.java.classpath.7=../lib/commons-pool-1.2.jar
    wrapper.java.classpath.8=../lib/dom4j.jar
    wrapper.java.classpath.9=../lib/hibernate3.jar
    wrapper.java.classpath.10=../lib/hsqldb-1.7.2.2.jar
    wrapper.java.classpath.11=../lib/java-getopt-1.0.12.jar
    wrapper.java.classpath.12=../lib/jmx.jar
    wrapper.java.classpath.13=../lib/jmxremote.jar
    wrapper.java.classpath.14=../lib/jmxri-1.2.1.jar
    wrapper.java.classpath.15=../lib/jmxtools-1.2.1.jar
    wrapper.java.classpath.16=../lib/junit-3.8.1.jar
    wrapper.java.classpath.17=../lib/ldap.jar
    wrapper.java.classpath.18=../lib/maven-directory-plugin-0.9.4-SNAPSHOT.jar
    wrapper.java.classpath.19=../lib/mx4j-tools.jar
    wrapper.java.classpath.20=../lib/mx4j.jar
    wrapper.java.classpath.21=../lib/mysql-connector-java-3.0.16-ga-bin.jar
    wrapper.java.classpath.22=../lib/nlog4j-1.2.17.jar
    wrapper.java.classpath.23=../lib/penrose-0.9.8.jar
    wrapper.java.classpath.24=../lib/velocity-dep-1.4.jar
    wrapper.java.classpath.25=../lib/wrapper.jar
    wrapper.java.classpath.26=../lib/zql.jar
  1. Java Library Path (location of Wrapper.DLL or libwrapper.so)
    wrapper.java.library.path.1=../lib
  1. Java Additional Parameters
    wrapper.java.additional.1=-Dpenrose.home=..
  1. Initial Java Heap Size (in MB)
    #wrapper.java.initmemory=3
  1. Maximum Java Heap Size (in MB)
    #wrapper.java.maxmemory=64
  1. Application parameters. Add parameters as needed starting from 1
    wrapper.app.parameter.1=org.safehaus.penrose.PenroseServer

#********************************************************************

  1. Wrapper Logging Properties
    #********************************************************************
  2. Format of output for the console. (See docs for formats)
    wrapper.console.format=PM
  1. Log Level for console output. (See docs for log levels)
    wrapper.console.loglevel=INFO
  1. Log file to use for wrapper output logging.
    wrapper.logfile=../var/penrose.out
  1. Format of output for the log file. (See docs for formats)
    wrapper.logfile.format=LPTM
  1. Log Level for log file output. (See docs for log levels)
    wrapper.logfile.loglevel=INFO
  1. Maximum size that the log file will be allowed to grow to before
  2. the log is rolled. Size is specified in bytes. The default value
  3. of 0, disables log rolling. May abbreviate with the 'k' (kb) or
  4. 'm' (mb) suffix. For example: 10m = 10 megabytes.
    wrapper.logfile.maxsize=0
  1. Maximum number of rolled log files which will be allowed before old
  2. files are deleted. The default value of 0 implies no limit.
    wrapper.logfile.maxfiles=0
  1. Log Level for sys/event log output. (See docs for log levels)
    wrapper.syslog.loglevel=NONE

#********************************************************************

  1. Wrapper Windows Properties
    #********************************************************************
  2. Title to use when running as a console
    wrapper.console.title=@app.long.name@

#********************************************************************

  1. Wrapper Windows NT/2000/XP Service Properties
    #********************************************************************
  2. WARNING - Do not modify any of these properties when an application
  3. using this configuration file has been installed as a service.
  4. Please uninstall the service before modifying this section. The
  5. service can then be reinstalled.
  1. Name of the service
    wrapper.ntservice.name=PenroseService
  1. Display name of the service
    wrapper.ntservice.displayname=Penrose Virtual Directory Server
  1. Description of the service
    wrapper.ntservice.description=http://penrose.safehaus.org
  1. Service dependencies. Add dependencies as needed starting from 1
    wrapper.ntservice.dependency.1=
  1. Mode in which the service is installed. AUTO_START or DEMAND_START
    wrapper.ntservice.starttype=AUTO_START
  1. Allow the service to interact with the desktop.
    wrapper.ntservice.interactive=false
Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators