[JBoss Microcontainer Development] New message: "Re: Native library mapping at jboss-cl level"
by Adrian Brock
JBoss development,
A new message was posted in the thread "Native library mapping at jboss-cl level":
http://community.jboss.org/message/520620#520620
Author : Adrian Brock
Profile : http://community.jboss.org/people/adrian@jboss.org
Message:
--------------------------------------------------------------
While I agree with adding something like the Bundle-NativeCode header to the ClassLoadingMetaData (CLMD),
that isn't what the ClassLoader should use at runtime.
The actual libraries will be unpacked into a temporary location which is a runtime detail so it needs to be a seperate piece of metadata
that is passed to the ClassLoaderPolicy at construction.
Its not declarativily declared by the person deploying the bundle.
I also disagree with what you've done in the OSGiBundleNativeCodeDeployer.
1) It should be generating a unique name for the library so that it can be hotdeployed (if the OS supports reloading native libraries).
2) It should be deleting the library when its no longer deployed (if it can, e.g. it won't be able to on Windows since the file will
likely be locked until the classloader is garbage collected - but could use createTempFile() so it gets deleted at shutdown).
3) You shouldn't use the BundleStoragePlugin. e.g. if this is running inside JBossAS, the libraries should be extracted to server/xxx/temp
not server/xxx/data
It would also be nice if the unpacking happened lazily. i.e. the metadata object that gets passed to the classloader policy unpacks it
when it is first used rather than doing it up front in the deployer.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520620#520620
16 years, 2 months
[JBoss ESB Development] New message: "Handling missing elements with Smooks"
by Mike Velikovich
JBoss development,
A new message was posted in the thread "Handling missing elements with Smooks":
http://community.jboss.org/message/520616#520616
Author : Mike Velikovich
Profile : http://community.jboss.org/people/mvelik
Message:
--------------------------------------------------------------
Hello,
I need to process a message which contains optional elements and transform it to another XML format. An XML is received from an external system and all elements are defined as optional. This means that if a value of the element is null, it will not exist in the file at all. We are using SMOOKS to handle transformations. SMOOKS recommends 2 ways of handling missing variables - one which uses an ! after the variable followed by the default value, and another one which uses <#if> tag and ?? syntax.
So far none of the above works.
Do you have any recommendations/examples?
Thank you in advance,
Mike
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520616#520616
16 years, 2 months
[JBoss Microcontainer Development] New message: "Re: Pluggable dependency resolver"
by Thomas Diesler
JBoss development,
A new message was posted in the thread "Pluggable dependency resolver":
http://community.jboss.org/message/520557#520557
Author : Thomas Diesler
Profile : http://community.jboss.org/people/thomas.diesler@jboss.com
Message:
--------------------------------------------------------------
Hi Kabir,
here is a quick describtion of how OSGi bundle resolution works.
For details see
Module Layer
http://www.osgi.org/Download/File?url=/download/r4v42/r4.core.pdf
http://www.aqute.biz/Sales/OSGi#core
When a bundle is http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#INSTALLED, only its constistency in terms of osgi metadata in the manifest is verified. There is no connection to other http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html established. From now on, the http://www.osgi.org/javadoc/r4v42/org/osgi/framework/launch/Framework.html is free to resolve the Bundle at any time. When a Bundle gets started (explicitly) it first becomes http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#RESOLVED and then http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#ACTIVE. For a Bundle to become RESOLVED all its required Package-Imports and other mandatory requirements must get sattisfied. If a Bundle fails to get RESOLVED it remains in the INSTALLED state and may get RESOLVED at a later time (when more requirements become available). In the transition from RESOLVED to ACTIVE the optionally associated http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleActivator.html... method is called. If that fails, the Bundle remains in state RESOLVED and the user may retry to start the Bundle again at some later time.
There are various operations that implicitly (try to) resolve a Bundle. These are
* http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#getResou...
* http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#loadClas...
and it varients. Note, that http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#getEntry... does NOT trigger bundle resolution. A Bundle can also get explicitly resolved through the http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/PackageAd... method.
During bundle resolution, so called 'wires' are established between the exporter of a package and its importers. The resolver may have multiple exporters for a given package name/version to choose from and the most common case is that a Bundle contains a certain package that it may also import from another Bundle. In this case the wire may get established to the Bundle itself. It is a 'self wire'.
The resolver is encouraged to find the best possible solution that leads to a consistent class space. A consistent class space is one that satisfies the requirements of all importers and a given package is only exported by one and only one exporter. This can become quite complicated, especially when exported packages define a 'uses' directive. The uses directive means that all Bundles in a class space must get wired (i.e. use) the same exporter for a given package. In the face of multiple possible wiring outcomes, the uses directive helps to make more deterministic choices. Generally the resolver should aim to resolve as many as possible Bundles by walking the tree of possible wirings. In case of many unresolved (i.e. hundreds of) Bundles this can become a very expensive operation. Equinox, disregards possible wirings after a certain level of complexity and may not find a good solution. Felix considers more possible solution but may take ages to finally return with "sorry can't do it". Currently, both Equinox and Felix work together on a standalone resolver that may be used by both frameworks (and hopefully) ours in the future.
Once a wiring is established, is is never changed unless the Framework is restarted or a set of Bundles is explicitly refreshed through the http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/PackageAd.... It is important to understand that http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#uninstall() does NOT remove the wiring. Even after a Bundle is uninstalled it is still possible to load classes from that Bundle. This is true, unless the uninstalled Bundle was never choosen as an exporter and there is no wiring to it. In this case it can be removed from the Framework straight away.
Here are a few requirements that I would have on the resolver API
* It must be possible to resolve multiple Modules at the same time
* Resolution must be based on mandatory/optional requirements and capabilities
* Environmental capablities (i.e. OS, JDK, NativeLibraries) may influence the resolver outcome
* It must be possible to 'try run' resolution and examine the potential outcome without affecting the running system
* The MC resolver should be adaptable to the Felix standalone resolver (details still unknown)
* The resolver must have an interface to a repository (i.e. OBR) to be able to pull in unstatisfied dependencies on demand
* perhaps others that I may need to add in the future ...
hope that helps
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520557#520557
16 years, 2 months
[JBoss ESB Development] New message: "Re: Smooks problem"
by Gilles Dupont Tagne Tagne
JBoss development,
A new message was posted in the thread "Smooks problem":
http://community.jboss.org/message/520447#520447
Author : Gilles Dupont Tagne Tagne
Profile : http://community.jboss.org/people/tagnegilles
Message:
--------------------------------------------------------------
Thanks Maurice for your help. I fund how to solve the problem. I wrote a ESB customer action GillesSmooksAction.java
package de.gilles.projects.splitteresb;
import java.io.ByteArrayInputStream;
import javax.naming.InitialContext;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;
import javax.xml.transform.stream.StreamSource;
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.milyn.Smooks;
import org.milyn.container.ExecutionContext;
import org.milyn.event.report.HtmlReportGenerator;
import org.milyn.persistence.util.PersistenceUtil;
import org.milyn.scribe.adapter.jpa.EntityManagerRegister;
public class GillesSmooksAction extends AbstractActionLifecycle {
protected ConfigTree _configTree;
public GillesSmooksAction(ConfigTree configTree){
_configTree = configTree;
}
public Message process(Message message) throws ActionProcessingException {
Smooks smooks = null;
EntityManagerFactory emf = null;
EntityManager em = null;
try {
String smooksConfigFile = _configTree.getAttribute("smooksConfig");
if(smooksConfigFile == null){
throw new Exception("The Attribute with the name: 'smooksConfig' doesn't exist." );
}
// emf = Persistence.createEntityManagerFactory("persondb");
// em = emf.createEntityManager();
InitialContext jndiContext = new InitialContext();
emf = (EntityManagerFactory) jndiContext.lookup("java:/personDbEntityManagerFactory");
em = emf.createEntityManager();
smooks = new Smooks(smooksConfigFile);
ExecutionContext executionContext = smooks.createExecutionContext();
executionContext.setEventListener(new HtmlReportGenerator("/Users/gilles/Desktop/report/reportjpa.html"));
PersistenceUtil.setDAORegister(executionContext, new EntityManagerRegister(em));
EntityTransaction tx = em.getTransaction();
tx.begin();
smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(((String)message.getBody().get()).getBytes())));
tx.commit();
} catch (Exception e) {
e.printStackTrace();
throw new ActionProcessingException(e);
}
finally{
try {
if(em != null) em.close();
} catch (Exception e2) {}
try {
if(emf != null) emf.close();
} catch (Exception e2) {}
if(smooks != null) smooks.close();
}
return message;
}
public void exceptionHandler(Message message, Throwable exception) {
logHeader();
System.out.println("!ERROR!");
System.out.println(exception.getMessage());
System.out.println("For Message: ");
System.out.println(message.getBody().get());
logFooter();
}
// This makes it easier to read on the console
private void logHeader() {
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
}
private void logFooter() {
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
}
}
Then i changed the jboss-esb.xml, persistence.xml and the dbSmooksConf.xml
jboss-esb.xml
<?xml version="1.0"?>
<jbossesb parameterReloadSecs="5"
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml... http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml...">
<providers>
<jms-provider connection-factory="ConnectionFactory" name="JbossMessaging">
<jms-bus busid="splitterChannel">
<jms-message-filter dest-name="/queue/splitterQueueAware" dest-type="QUEUE"/>
</jms-bus>
</jms-provider>
<schedule-provider name="CronSchedulerProvider">
<cron-schedule cronExpression="0/3 * * * * ?" scheduleid="myCronSchedule"/>
</schedule-provider>
<fs-provider name="FileSystemProvider">
<fs-bus busid="esbFileSystem">
<fs-message-filter directory="/Users/gilles/Desktop/ESB/Input"
error-delete="false"
error-directory="/Users/gilles/Desktop/ESB/Error"
error-suffix=".error" input-suffix=".csv" post-delete="true"
post-directory="/Users/gilles/Desktop/ESB/Post" post-suffix=".post" work-suffix=".work"/>
</fs-bus>
</fs-provider>
</providers>
<services>
<service category="splitterTest" description="Splitt the .csv file"
invmScope="GLOBAL" name="fileSplitter">
<listeners>
<fs-listener busidref="esbFileSystem" is-gateway="true"
name="FileListener" scheduleidref="myCronSchedule">
<property name="composer-class" value="org.jboss.soa.esb.smooks.splitting.FileStreamSplitter"/>
<property name="splitterConfig" value="/mySmooksConf.xml"/>
</fs-listener>
</listeners>
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.SystemPrintln" name="Print">
<property name="message" value="[Splitter] Message Split complete"/>
</action>
</actions>
</service>
<service category="splitterTest"
description="Route the message to a jms queue" invmScope="GLOBAL" name="routerSplitter">
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.Notifier" name="NotifyAction1">
<property name="destinations">
<NotificationList type="ok">
<target class="NotifyQueues">
<queue jndiName="queue/splitterQueue"/>
</target>
</NotificationList>
</property>
<property name="okMethod" value="notifyOK"/>
</action>
</actions>
</service>
<service category="splitterTest"
description="Route the age element of the message to a jms queue"
invmScope="GLOBAL" name="routerAgeSplitter">
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.Notifier" name="NotifyAction2">
<property name="destinations">
<NotificationList type="ok">
<target class="NotifyQueues">
<queue jndiName="queue/splitterAgeESBQueue"/>
</target>
</NotificationList>
</property>
<property name="okMethod" value="notifyOK"/>
</action>
</actions>
</service>
<service category="splitterTest" description="Make routing on Age"
invmScope="GLOBAL" name="recipientListAge">
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.StaticRouter" name="staticRoutingAge">
<property name="destinations">
<route-to destination-name="ToRouterAgeSplitter"
service-category="splitterTest" service-name="routerAgeSplitter"/>
<route-to destination-name="ToDbPersistAge"
service-category="splitterTest" service-name="dbPersist"/>
</property>
</action>
</actions>
</service>
<service category="splitterTest"
description="Persist data in the database" invmScope="GLOBAL" name="dbPersist">
<actions mep="OneWay">
<action class="org.jboss.soa.esb.actions.SystemPrintln" name="PrintMessage1">
<property name="message" value="Message"/>
</action>
<action class="org.jboss.soa.esb.smooks.SmooksAction" name="smoksActionXML">
<property name="smooksConfig" value="/xmlSmooksConf.xml"/>
</action>
<action class="org.jboss.soa.esb.actions.SystemPrintln" name="PrintMessage2">
<property name="message" value="Message"/>
</action>
<!-- GillesSmooksAction -->
<action class="de.gilles.projects.splitteresb.GillesSmooksAction" name="dbPersist">
<property name="smooksConfig" value="/dbSmooksConf.xml"/>
</action>
</actions>
</service>
</services>
</jbossesb>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd ">
<persistence-unit name="persondb" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:/SplitterSqlDB</non-jta-data-source>
<class>de.gilles.projects.splitteresb.PersonAge</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="jboss.entity.manager.factory.jndi.name" value="java:/personDbEntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
dbSmooksConf.xml
<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
xmlns:dao="http://www.milyn.org/xsd/smooks/persistence-1.2.xsd">
<params>
<param name="stream.filter.type">SAX</param>
</params>
<jb:bean beanId="personage" class="de.gilles.projects.splitteresb.PersonAge" createOnElement="person">
<jb:value property="id" data="person/id" decoder="Integer"/>
<jb:value property="age" data="person/age" decoder="Integer"/>
</jb:bean>
<dao:inserter beanId="personage" insertOnElement="person"/>
</smooks-resource-list>
It works
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520447#520447
16 years, 2 months