środa, 17 maja 2017

Datapower running on AWS instance (from AWS marketplace) - NTP server configuration

Managing Datapower instance from AWS - changing date and time and synchronizing time with NTP



1. It turned out that if Datapower runs on Linux - it doesn't have NTP service available:

https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.5.0/com.ibm.dp.doc/ntp-service_global.html

http://www-01.ibm.com/support/docview.wss?uid=swg21991499&myns=swgws&mynp=OCSS9H2Y&mync=R&cm_sp=swgws-_-OCSS9H2Y-_-R

2. Datapower inherits NTP configuration from its OS environment

3. Install NTP on redhat: https://www.tecmint.com/install-ntp-server-in-centos/

4. Then do all steps from

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-Date_and_Time_Configuration-Command_Line_Configuration-Network_Time_Protocol.html

5. It is worth to remember that ntpd will not start on boot if chrony is enabled. In order to disable it - perform all steps from here: http://thegeekdiary.com/centos-rhel-7-enable-ntp-to-start-at-boot-after-fresh-install-disable-chrony/

6. Now if you restart your instance ntp will be enabled but in order to configure correct time zone for datapower you need to go to your console Administrator - Device - Time Settings

7. If you also need to change time zone on your redhat please take a look at these links:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html

piątek, 28 kwietnia 2017

AIX - installing software, scp and others

In order to test your app on AIX you can lease AIX daily/monthly etc from : https://www.siteox.com

SSH:
ssh -X -p 8822 yrwbko@cloud.siteox.com (password will be given by siteox)

SCP:
firstly install sshpass then:
sshpass -p "password" scp -P 8822 /path/your-file root@cloud.siteox.com:/target-path

To install wget on AIX follow:
http://letmehelpyougeeks.blogspot.com/2012/09/installing-common-softwares-like-wget.html

To check public IP of your instance:
curl ipecho.net/plain

To install unzip/zip:
1. Download unzip rpm from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
2. sshpass -p "pass" scp -P 8822 ~/Downloads/unzip-6.0-3.aix6.1.ppc.rpm root@cloud.siteox.com:/opt/
3. rpm -ivh unzip-6.0-3.aix6.1.ppc.rpm


Useful:
https://www.ibm.com/developerworks/aix/library/au-aix_cmds/

Installing java:
1. Download .bin folder from IBM site,
2. SCP bin folder to AIX
3. chmod a+x ....bin
4. If you have issues with disk space use for example  chfs -a size=+2G /opt
5. IATEMPDIR=/opt/tmp
   export IATEMPDIR
6. ./....bin and follow instructions (set java path )

środa, 5 października 2016

How to change text inside the component to have vertical position

Assuming that your text is inside span component you can just add css:

Primefaces Datatable with editable rows, add button and remove button

So the goal is to implement something like that:







So as you can see we have editable component. It is possible to add new row. When the row is being edited Apply button is disabled and also when you add new row the row is automatically set to edit mode.
Let's take a look at the implementation:
This is an implementation of a from containing datable:

As you can see we used jsf compositions here. Take a look at the implementation of datatable:

And finally bean implementation:

Notice that Remove button inside third column is in the same line as Edit, Check and Close buttons. This is not a default behaviour - in order to achieve that you need to add following css:

Implementing commandButton which looses focus after onmouseup

I noticed that on chrome - commandButton from Primefaces doesn't loose focus after clicking on it. This is different behaviour than on Firefox. In order to change it you need to just add attribute

onmouseup="this.blur();"

So your commandButton implementation may look like this:

<p:commandButton 
id="moveUpButton" process="@this" immediate="true"
onmouseup="this.blur();" update="orchestrationTaskDiagram moveDownButton moveUpButton"
actionListener="#{projectAdminBean.moveUpActionListener}" 
icon="ui-icon ui-icon-arrowthick-1-n" title="Move Task Up" 
styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default" 
disabled="#{!canSaveChanges or !projectAdminBean.editMode or !projectAdminBean.isMoveUpEnabled()}" />

sobota, 28 marca 2015

piątek, 20 marca 2015

Using files from resources in your tests

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;


URL infoFileURL = ProjectServiceImplTest.class.getResource("/log4jINFO.properties");
testLogFileWithINFOLevel = new File(infoFileURL.toURI());

poniedziałek, 7 stycznia 2013

Java programming interview questions:
  1. What is immutable object? Can you write immutable object?
    • Immutable classes are java classes whose object can not be modified once created. Any modification in Immutable object result in new object. For example String is immutable object. Mostly immutable are also final in order to prevent sub class to overriding method in Java. You can achieve the same functionality by making member as non final but private and not modifying them except constructors.
  2. What is Static and Dynamic binding in Java
  3. Overloading and Overriding method
  4. How to override compareTo method
  5. final variable, method and class in Java
  6. What is static variable, class, method and keyword in Java
    • static keyword may be applied with variable, method or nested class (cannot be applied with top level class)
    • static variables are asociated with class instead of object, and keeps same value for every single object
    • you can not use non-static variable inside a static method
    • static binding, class loading
  7. How Garbage collector works, and how System.gc() method works
  8. What is reflection
    • Reflection is the ability of running program to examine/analyse itself and its software environment. To perform this self-examination, a program needs to have a representation of itself. This information we call metadata. In object oriented world metadata is organized into objects, called metaobjects and the run time self examination of the metaobjects is called introspection.
    • I didn't use reflection very oftenby myself, but I know that it is used in many java frameworks - for example Spring container uses reflection to create the objects. 
  9. Why main method is static in Java
  10. Class loading in Java

sobota, 5 stycznia 2013

Spring interview questions

  1. What is IOC 
    • Inversion of Control means that we have inverted the control of creating the object from our own using new operator to container or framework. It's the responsibility of container to create object as required. We maintain one xml file where we configure our components, services and all classes and their property. We just need to mention which service is needed by which component and container will create the object for us. This concept is known as dependency injection
  2. Explain Bean LifeCycle
    • Container will look the bean definition inside the configuration file (bean.xml)
    • Using reflection container will create the object and if any property is defined inside the bean definition then it will be also set
    • If the bean implements the BeanNameAware interface the factory calls setBeanName() passing the bean's ID
    • If the bean implements the BeanFactoryAware interface the factory calls setBeanFactory() passing an instance of itself
    • If there are any BeanPostProcessors associated with the bean their post- ProcessBeforeInitialization() methods will be called before the properties for the Bean are set. 
    • If an init() method is specified for the bean, it will be called
    • If the Bean class implements the DisposableBean interface, then the method destroy() will be called when the Application no longer needs the bean reference.
    • If the Bean definition in the Configuration file contains a 'destroy-method' attribute, then the corresponding method definition in the Bean class will be called.
  3. What is BeanFactory
  4. Difference between BeanFactory and ApplicationContext
  5. What are the different modules in Spring
  6. Difference between Singleton and Prototype bean
  7. What type of Transaction Management Spring support.
  8. What is AOP
  9. Explain advice
  10. What is joing point and pointcut
  11. How to configure Hibernate with Spring
  12. Transaction propagation types in Spring

piątek, 28 grudnia 2012

Java IO interview questions

  1. What is Java Streams
    • Briefly: Java IO streams are flows of data you can either read from, or write to.  Streams are typically connected to a data source or data destination like a file, network connection. In Java streams are typically byte based. When you have to write component that needs to read input from a stream you can use InputStream (or one of its subclasses e.g. FileInputStream). Whereas when you have to write component that needs to write output to a stream you can use OutputStream (or one of its subclasses e.g. FileOutputStream). 
    • I had the opportunity to use Java IO streams in small projects during my studies, when I had to read/write not large amount of data. But recently at work I have implemented solution consisted of saving all the data coming from trading system to a file. That data related to the current date only. I have tested solution based on the use of Java IO Streams and Java NIO Buffers and I have found that Java NIO Buffers can do the same job up to ten times faster.  
  2. What is Reader and Writer in Java IO
    • Briefly: Java IO's readers and writers work much like InputStrem and OutputStream with the exception that Readers and Writers are characted based. They are intended for reading and writing text. 
    • I used Readers and Writers only in small projects during my studies. 
  3. Which of them is byte base and which is char based
    • Streams are byte based whereas Readers and Writers are char based
  4. NIO and IO
  5. Reading and writing text file in Java
  6. Creating file and Directory in Java
  7. Memory Mapped File in Java

wtorek, 9 października 2012

Some examples from my daily tasks part 1


I have to design and implement mechanism which handle such situation:
There are two applications, let's say App1 and App2 and OpenMQ Broker between those applications. Furthermore there are two queues on this Broker - ControlQueue and DataQueue.
Under normal conditions (when both App1 and App2 are alive) App1 sends some real time data to DataQueue and App2 receives that data. App1 caches data and has a refresh functionality in case App2 need to update all data.


  1. App2 to maintain connection every ten seconds sends PING message to ControlQueue. 
  2. App1 receives PING messages from ControlQueue and saves the time of last PING message.
  3. Every time App1 receives PING message it checks if data is sending to DataQueue. If not, it launches refresh and send cached and real time data to DataQueue. 
  4. App1 (by QueueConectionMaintainer) checks every ten seconds if time of last PING message is later than 25 seconds and if yes then it stop sending data to DataQueue. 
App1 is created with Spring Integration and use jms:inbound-channel-adapter to receive messages from ControlQueue. 

Ad.1.
 PING message is a jms object message with Properties object inside
Ad.2, Ad.3
Connection with OpenMQ - Spring Integration configuration:


Connection factory decorator:


Queue listener - Spring Integration configuration:

ControlQueueListenerActivator implementation:

Ad.4 Queue connection maintainer - Spring Integration configuration: QueueConnectionMantainer implementation:

czwartek, 4 października 2012

Into the Effective Java part. 1

Using static factory methods instead of constructors. *
 Advantages:

  • Unlike constructors they have names. 
If the parameters to a constructor do not, in and of themselves, describe the object being returned, a static factory with a well-chosen name is easier to use and the resulting client code easier to read.
  • They are not required to create a new object each time they're invoked. 
The ability of static factory methods to return the same object from repeated invocations allows classes to maintain strict control over what instances exist at any time.
  • They can return an object of any subtype of their return type. 
This gives you great flexibility in choosing the class of the returned object.
  • They reduce the verbosity of creating parameterized type instances.  
Unfortunately, you must specify the type parameters when you invoke the constructor of a parameterized class even if they’re obvious from context.
With static factory methods instead of doing: 


You can implement:

Then you could replace the wordy declaration above with this succinct alternative:

Disadvantages:
  • The main disadvantage of providing only static factory methods is that classes without public or protected constructors cannot be subclassed.
  • A second disadvantage of static factory methods is that they are not readily distinguishable from other static methods.
They do not stand out in API documentation in the way that constructors do, so it can be difficult to figure out how to instantiate a class that provides static factory methods instead of constructors.


* Effective Java Second Edition, Joshua Bloch

poniedziałek, 1 października 2012

Into the Spring part 1

How does spring simplify Java development?
Key strategies:

    • Lightweight and minimally invasive development with plain old Java objects (POJOs)
    • Loose coupling through dependency injection and interface orientation
    • Declarative programming  through aspects and common conventions 
    • Boilerplate reduction through aspects and templates
Almost everything Spring does can be traced back to one or more of these four strategies*. 





*Spring in Action 3rd edition, Craig Walls

czwartek, 27 września 2012

My portfolio

1. Brokerage system for Bank A
 - Implementation of module to call remote, transactional system’s web-services using SOAP 1.1 protocol and WSDL based interfaces. Creating data contract between a service and a client.
 - Implementation of monitor core module to asynchronous communication with a transactional system.
 - Working with data access, business and presentation layers.
JMS 1.1, EJB 3.0, JAXB 2.0, JAXWS 2.1, Weblogic 10.0 SP1,SVN

2. Internet Investments system for Bank B.
 - Service, technical support and CR implementation
JDK 1.5, JAVA Servlet API, AJAX, viBank Templates, CVS

3. Client system for Bank A
- Working with presentation layer for brokerage part of the system. Client side development.
JDK 1.5, Spring Portlet MVC, jQuery,SVN

4. Brokerage system for Bank C
- Implementation of module to call remote, transactional system’s web-services using SOAP 1.1 protocol and WSDL based interfaces. Creating data contract between a service and a client.
JAXB 2.0, JAXWS 2.1,JBossWS

5. Central Brokerage system for Bank C
- Design, implementation of web-services
JDK 1.6, Gigaspace 7/8 XAP In-Memory Data Grid, Spring 3.0, Groovy, EJB 3.0, JMS 1.1, JAXWS 2.1, Hibernate 3.3,SVN,TestNG,

6. XDP protocol based, quotation system for rapid market data distribution (http://www.nyse.com) for Bank C
- Implementation of XDP adapter module.
Spring Integration, Spring Dynamic Modules,  OSGi R4.,  SVN,  XDP financial protocol

So let's get started...

First blog - first post.
I am a Java programmer with a pretty good experience and expertise in a many interesting projects.
So why still Java Layman?  Beacuse I think that I still don't have enough knowledge. In my job - I was always the man of everything. I mean I was doing everything with "yesterday" as a deadline witch unfortunately meant that I learned only this part of the technology that I needed. And now, I have 3 - year experience and huge gaps in my theoretical knowledge. Starting today - I am going to eliminate them.
My dream: Senior Java Developer in London
My problems to solve: Gaps in theoretical knowledge, poor English speaking.