I tried to look through the websites and documents but I cannot find blueprint equivalent of util:list from Spring? Did I overlook something? if is not there, what would be the alternative? In either case, I need a list of beans injected into another bean - was planning to use util:list but..
Did you try this?
<bean id="myList" class="java.util.ArrayList">
<argument>
<list value-type="com.example.MyType">
<ref component-id="mycomponent1"/>
<ref component-id="mycomponent2"/>
<ref component-id="mycomponent3"/>
<bean class="com.example.MySubType"/>
</list>
</argument>
</bean>
ArrayList takes a Collection as constructor argument (as does LinkedList btw.). So you just create a bean of type List and provide the list of bean references or beans in the constructor.
There should be a list-element in the http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd namespace.
The set of "value" types that can be used in any place a value
can be specified. This set includes the < ref > and < idref > elements, any of the
component types (< bean >, < service >, etc.) as inline components, the
generic element for types sourced from string values, any of the
collection types (< set >, < list >, < array >, < map >, < props >), and the
< null > type to inject a null value.
Also, you can find an example here: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.aries.blueprint/org.apache.aries.blueprint.sample/0.4/OSGI-INF/blueprint/config.xml
Related
I have treed as below
<iterate xmlns:oag="http://www.openapplications.org/oagis/10" xmlns:fn="http://www.w3.org/2005/xpath-functions" continueParent="true" preservePayload="true" attachPath="//ProcessCredit/DataArea" expression="//ProcessCredit/DataArea/Credit sequential="true">
.....
<property xmlns:ns="http://org.apache.synapse/xsd"
xmlns:oa="http://www.openapplications.org/oagis/10"
name="ChargeTransactionKey"
expression="concat(get-property('operation','ChargeTransactionKey'),//Extension/ValueText[#typeCode='Charge Transaction Key'],':')"
scope="operation"
type="STRING"
description="ChargeTransactionKey"/>
...........
</iterate >
<log level="full">
<property name="requestIdChargeTransactionKey"
expression="get-property('operation','ChargeTransactionKey')"/>
</log>
but value in property "requestIdChargeTransactionKey" is null, it means I'm unable to capture the property which is defined inside iterator.
can anybody help on syntax?
The mediation inside iterate works with clones of MessageContext. If you continue parent mediation (set continueParent attribute to true), you work with the initial MessageContext and therefore all the properties you have set with scope 'default' inside iterate are lost
But there is a scope named 'operation' used to retrieve a property in the operation context level and if you set a property with this scope inside iterate, you can get it's value in the parent mediation
Inside iterate :
<property name="ChargeTransactionKey" value="xxx" scope="operation"/>
In parent mediation :
get-property('operation','ChargeTransactionKey')
WSO2 Documentation, You can fetch the property in the operation context level from the operation scope.
The properties within iterated/cloned message with the operation scope are preserved in the sequence even if you have configured your API resources to be sent through the fault sequence when faults exist.
get-property('operation', String propertyName)
A given property with the operation scope only exists in a single request and can be accessed by a single resource. The properties in this scope are passed to the error handler when the FORCE_ERROR_ON_SOAP_FAULT property is set to true
I'm using last version of Jasig CAS server (4.0.0) with an LDAP server.
Users are stored under this LDAP structure : ou=Users,ou=SSOTEST,dc=mycompany,dc=com
What I want is to search an user from a top level (example : ou=SSOTEST,dc=mycompany,dc=com).
CAS server has an LdapPersonAttributeDao bean which is looking for an object matching a search filter. Here is the code for this bean :
<bean id="ldapPersonAttributeDao"
class="org.jasig.cas.persondir.LdapPersonAttributeDao"
p:connectionFactory-ref="searchPooledLdapConnectionFactory"
p:baseDN="ou=SSOTEST,dc=company,dc=com"
p:searchControls-ref="searchControls"
p:searchFilter="uid={0}">
<property name="resultAttributeMapping">
<map>
<!--
| Key is LDAP attribute name, value is principal attribute name.
-->
<entry key="memberOf" value="userMemberOf" />
<entry key="cn" value="userCn" />
</map>
</property>
</bean>
And now the searchControls bean which do a lookup at SUBTREE_SCOPE (2) level (according toSearchControls scope level values).
<bean id="searchControls"
class="javax.naming.directory.SearchControls"
p:searchScope="2"
p:countLimit="10" />
When I run my CAS server and I try to authenticate, everything works but there are no extra attributes returned.
I think the problem comes from searchScope, which don't seems to be set to wanted value.
Here is output log from the server :
<execute request=[org.ldaptive.SearchRequest#-1312441815::baseDn=ou=SSOTEST,dc=mycompany,dc=com, searchFilter=[org.ldaptive.SearchFilter#-3391
91059::filter=uid={0}, parameters={0=myuser}], returnAttributes=[], searchScope=null, timeLimit=0, sizeLimit=10 [...]
I know its been some time since this question was asked. But I managed to fix this problem by adding:
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
to deployerConfigContext.xml.
The cause of this issue was that the initalize method in LdapPersonAttributeDao was not being invoked because the #PostConstruct annotation wasn't being executed. For this reason the searchScope variable was never set.
I've been having trouble with Camel transactions and after some great help from the camel list I eventually tracked it down to using org.apache.activemq.camel.component.ActiveMQComponent in a bean with id 'activemq'. If I use an id of 'activemqTx' it works. But I can't seem to find any documentation on the significance of 'activemqTx' as a bean id.
only one message gets through the route with this:
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
everything works with this:
<bean id="activemqTx" class="org.apache.activemq.camel.component.ActiveMQComponent">
Must have been a bean name clash
I'm writing a simple bean that I want to configure with a table name, an XML file with some data, so that if at application startup the table is empty it get initialized with that data. I decided to use simple SQL queries, but I can't get a session from the sessionfactory, because it says:
Error creating bean with name 'vecchiOrdiniFiller' defined in ServletContext resource [/WEB-INF/spring/servlet-context.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
But this is the configuration (very similar to a service):
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory" />
</bean>
<tx:annotation-driven />
<bean id="ordiniVecchioSistemaLoader" class="it.jsoftware.jacciseweb.assistenza.common.ExcelXmlDataLoader">
<property name="xmlFileName" value="WEB-INF/data/daticlientijaccisemarco.xml"></property>
</bean>
<bean id="vecchiOrdiniFiller" class="it.jsoftware.jacciseweb.assistenza.common.BaseTableFiller" init-method="init">
<property name = "sessionFactory" ref = "mySessionFactory"></property>
<property name="loader" ref="ordiniVecchioSistemaLoader"></property>
<property name="tableCreationString" value="CREATE TABLE `vecchiordini` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `codicejazz` VARCHAR(255) DEFAULT NULL, `progressivolicenza` INT(11), `codicearticolo` VARCHAR(255) DEFAULT NULL, `rivenditore` VARCHAR(255) DEFAULT NULL, `cliente` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`ID`)) ENGINE=INNODB DEFAULT CHARSET=utf8"></property>
<property name="table" value="vecchiordini"></property>
<property name="tableColumns">
<list>
<value>codicejazz</value>
<value>progressivolicenza</value>
<value>codicearticolo</value>
<value>rivenditore</value>
<value>nomecliente</value>
</list>
</property>
<property name="loaderColumns">
<list>
<value>clicod</value>
<value>licsmatricola</value>
<value>artcod</value>
<value>rivenditore</value>
<value>cliente</value>
</list>
</property>
</bean>
and I annotated the init() method with #Transactional. But it doesn't start a transaction and I get that error:
#Transactional
public void init() throws Exception {
logger.info("BaseTableFilter per tabella: " + table + ", usando: "
+ loader.getSourceName());
Session session = dao.getSession();
Transaction tx = session.beginTransaction();
...
why doesn't that work?
The init-method or #PostConstruct annotated methods are not proxied, so you will not be able to use #Transactional on that. You should use #Transactional on your service, why is that not suitable for you?
Quoted from the SpringSource Jira:
This is as defined, actually: init methods (such as #PostConstruct methods) are always called on the target instance itself. The proxy will only be generated once the target instance has been fully initialized... In other words, the #Transactional proxy isn't even created at the point of the #PostConstruct call yet.
Switching to mode="aspectj" would help since it weaves the target class directly, in which case the init method will have been modified for transactional awareness at the time of the container init call already.
I guess at the very minimum, we should document the limitations of #Transactional on proxies more clearly - and point out where mode="aspectj" might be a solution.
As stated, you can try the mode="aspectj" but rather you should review your design in my opinion.
I don't think you can make the init method transactional. But you can invoke another transactional method of another service from it.
How can I change the connection string from nhibernate.config file using nant
the problem is that all examples are about changing attribute value, but nhibernate has inner text
eq:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string">Data Source.\server;Database=UnitTestDb;UID=user;pwd=pass;</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="show_sql">true</property>
<property name="connection.release_mode">auto</property>
<property name="adonet.batch_size">500</property>
....
I need to change property connection.connection_string
<xmlpoke file="${nhibernate.file}"
xpath="/hibernate-configuration/session-factory/add[#key='connection.connection_string']/#value"
value="${connection.string}">
</xmlpoke>
this does not work in this case.
Thanks
The sample xpath you're using refers to elements named add with attributes called key. In your case you are looking for property elements with attributes called name.
Next, since you want to change the inner text and not the #value attribute on the property element you should remove the trailing attribute reference.
And finally, since the NHibernate xml has a specific namespace you will have to inform xmlpoke to use the correct namespace.
So the task should look like this:
<xmlpoke file="${nhibernate.file}"
xpath="/nhc:hibernate-configuration/nhc:session-factory/nhc:property[#name='connection.connection_string']"
value="${connection.string}">
<namespaces>
<namespace prefix="nhc" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
Note: I've not tested this out, but general xml/xpath rules are in work here so I hope it works. Also, it could be that there is a way to indicate to xmlpoke that the specified namespace should be the default and thus eliminate the need to namespace prefix all the various parts in the xpath.
Good luck!