Sunday, July 23, 2017

Change material of a primitive object on Papervision object using BitmapFileMaterial

Change Material of a Primitive Object on Papervision3D Using BitmapFileMaterial

When working with Papervision3D, applying custom materials (textures) to 3D objects is a common requirement. One such approach is using the BitmapFileMaterial class. To avoid runtime issues with asset paths, it's best to embed both the 3D model and texture images directly into your ActionScript project.

Step 1: Embed Model and Texture Assets

Use the [Embed] directive to load both your DAE (Collada) model and the associated texture bitmap:

[Embed(source = "assets/Guitar.dae", mimeType = "application/octet-stream")]
private var LoadGuitar:Class;

[Embed(source = "assets/Guitar/guitarTexture.png", mimeType = "application/octet-stream")]
private var LoadGuitarTexture:Class;

By embedding assets this way, you eliminate file path issues and ensure that assets are bundled within the SWF, making your 3D application more portable and reliable.

Next Steps

Once you have the model and texture embedded, you can proceed to:

  • Instantiate the Collada object from the LoadGuitar class
  • Create a BitmapFileMaterial using LoadGuitarTexture
  • Apply the material to the Collada mesh or any primitive you create

Example

Here is a simple example of applying the material to a 3D object:

// Create material from embedded bitmap
var texture:Bitmap = new LoadGuitarTexture() as Bitmap;
var material:BitmapFileMaterial = new BitmapFileMaterial(texture.bitmapData);
material.smooth = true;

// Load the model
var guitarModel:Collada = new Collada(new LoadGuitar(), material);

// Add to scene
scene.addChild(guitarModel);

Conclusion

Using embedded assets with BitmapFileMaterial ensures efficient and portable material application in Papervision3D. This method works great for offline builds or asset-heavy 3D Flash experiences where external loading may cause delays or complications.

Wednesday, April 12, 2017

IBM MQ from Spring using JMS

2 Ways to Connect to IBM MQ from Spring using JMS

Java Messaging Service (JMS) provides a standard way for Java applications to communicate with messaging systems like IBM MQ. In Spring applications, there are two primary approaches to connect to IBM MQ using JMS.

1. Using com.ibm.mq.jms.context.WMQInitialContextFactory

This method relies on JNDI-based lookups to retrieve connection factories and destinations. It is typically used in environments where resources such as ConnectionFactory and Queue are preconfigured on the application server (e.g., WebSphere).

This approach is suitable when you want to externalize configuration and rely on a container-managed environment.

java.naming.factory.initial = com.ibm.mq.jms.context.WMQInitialContextFactory
java.naming.provider.url = tcp://hostname:1414

2. Using com.ibm.mq.jms.MQQueueConnectionFactory

This is a programmatic approach that integrates seamlessly with Spring’s configuration. You can define the MQ connection directly in your Spring configuration files. Here's an example:

<!-- JMS Connection Factory -->
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="queueManager" value="QM1"/>
    <property name="hostName" value="localhost"/>
    <property name="port" value="1414"/>
    <property name="channel" value="DEV.APP.SVRCONN"/>
    <property name="transportType" value="1"/>
</bean>

<!-- JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

Using XA (Transactional) Connections

For distributed transactions that span across MQ and databases, configure XA support with Spring and IBM MQ as shown below:

<!-- Transaction Proxy Template -->
<bean id="txProxyTemplate" abstract="true"
      class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
        <props>
            <prop key="archiveTrades">PROPAGATION_REQUIRED,-Exception</prop>
            <prop key="processUpload">PROPAGATION_REQUIRED,-Exception</prop>
            <prop key="sendRTM">PROPAGATION_REQUIRED,-Exception</prop>
        </props>
    </property>
</bean>

<!-- JOTM Transaction Manager -->
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>

<bean id="transactionManager"
      class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="userTransaction" ref="jotm"/>
</bean>

<!-- XA DataSource -->
<bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource"
      destroy-method="shutdown">
    <property name="transactionManager" ref="jotm"/>
    <property name="driverName" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:oci:@DB_NAME"/>
    <property name="user" value="username"/>
    <property name="password" value="password"/>
</bean>

<!-- Pooled XA DataSource -->
<bean id="connectionDS" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
      destroy-method="shutdown">
    <property name="dataSource" ref="innerDataSource"/>
    <property name="user" value="username"/>
    <property name="password" value="password"/>
    <property name="maxSize" value="10"/>
</bean>

<!-- XA-aware MQ Connection Factory -->
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQXAQueueConnectionFactory">
    <property name="queueManager" value="QM_hostname"/>
    <property name="hostName" value="hostname"/>
    <property name="port" value="1414"/>
    <property name="transportType" value="1"/>
</bean>

<!-- MQ Queue Destination -->
<bean id="destination" class="com.ibm.mq.jms.MQQueue">
    <property name="targetClient" value="1"/>
</bean>

<!-- JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

Summary

Method Use Case Benefits
WMQInitialContextFactory Managed server environments (e.g., WebSphere) Centralized config via JNDI
MQQueueConnectionFactory Standalone Spring Boot or XML apps Direct, programmatic setup
MQXAQueueConnectionFactory Transactional messaging (with XA) Full integration with JTA and DB transactions

With either method, Spring’s abstraction via JmsTemplate makes working with IBM MQ and JMS much easier. Choose the right approach based on your deployment model and whether or not you need distributed transactions.

Friday, January 13, 2017

SSL certification of you web site

This will create a certification file and send to free certification authority "https://certbot.eff.org" sponsored by linux foundation.

Following are for apache deployment on Ubuntu compatible.
For other configurations visit https://certbot.eff.org

sudo apt-get install python-letsencrypt-apache
sudo letsencrypt --apache