Mar 25

Cause generics in Java 1.5 and 1.6 are implemented using erasure, in most cases you can not get class object for type parameter, which means that in your generic classes you can not instantiate objects of type parameters. For example, the following code will not compile:

class Foo<T> {
        T field;
        public void bar() {
                field = new T(); // error
        }
}

Read the rest of this entry »

Mar 23
Java version of gstpw
icon1 Seweryn Niemiec | icon2 | icon4 03 23rd, 2007| icon32 Comments »

jstpw
I like Java much more (about 38 times more) than C/C++. So I have written Java version of gstpw. Java version of course has more features :) and needs less lines of code to implement them. Moreover I have provided possibility to start it:

  • as standalone by $ java -jar jstpw.jat
  • via WebStart: webstart
Mar 21
gstpw – a simple stopwatch program
icon1 Seweryn Niemiec | icon2 | icon4 03 21st, 2007| icon31 Comment »

screenshot of gstpw I could not find under Ubuntu any stopwatch program with modern GUI. There was only one available: “Stopwatch” by Don Libes, but it uses Tcl/Tk, so it is ugly and starts long time. Yesterday I have written new one in C. It is “one file program” which needs GTK > 2.0. Project’s home page can be found here: gstpw

Mar 5

If you get very strange results using Copy&Paste in GMF diagram editor then in all likelihood your EMF model doesn’t use Universally Unique Identifiers. EMF’s XMIResourceImpl supports generation of UUID transparently but it’s disabled by default. To enable it you have to overwrite XMIResourceImpl‘s useUUIDs() method and make model plug-in use that new Resource implementation.

  1. Overwrite useUUIDs()
  2. Create new class which extends XMIResourceImpl and overwrites useUUIDs(). Put it for example in yourmodel.utils package.

    package mymodel.util;
    
    import org.eclipse.emf.common.util.URI;
    import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
    
    public class MymodelResource extends XMIResourceImpl {
    
            public MymodelResource() {
                    super();
            }
    
            public MymodelResource(URI uri) {
                    super(uri);
            }
    
            /* (non-Javadoc)
             * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#useUUIDs()
             */
            protected boolean useUUIDs() {
                    return true;
            }
    }
    
  3. Prepare special ResourceFactory
  4. This ResourceFactory factory should always create instances of MymodelResource class.

    package mymodel.util;
    
    import org.eclipse.emf.common.util.URI;
    import org.eclipse.emf.ecore.resource.Resource;
    import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
    
    public class MymodelResourceFactory extends XMIResourceFactoryImpl {
    
            public MymodelResourceFactory() {
                    super();
            }
    
            /* (non-Javadoc)
             * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl#createResource(org.eclipse.emf.common.util.URI)
             */
            public Resource createResource(URI uri) {
                    return new MymodelResource(uri);
            }
    }
    
  5. Wire new ResourceFactory with model plug-in
  6. To plug.xml of your model plug-in add extension_parser extension:

       <extension point="org.eclipse.emf.ecore.extension_parser">
          <parser
             type="gnmsmodel"
             class="com.globalus.globnms.model.gnmsmodel.util.GnmsmodelResourceFactory">
          </parser>
       </extension>
    

All done. Now when you modify your model and save it you will get UUID’s stored in XMI file. This will of course bread relations from GMF’a notation model. Notation model should be deleted and initialized again.

[ratings]

Mar 4
New Project: netdgrm
icon1 Seweryn Niemiec | icon2 | icon4 03 4th, 2007| icon3No Comments »

I have just created new project named netdgrm (code.google.com requires lower letters for projects names, so I use this convention here too). It’s simple graphical editor for diagrams of computer networks. Project’s page is here. There is a screenshot and first pre alpha 0.0.1 release. It’s very stable but lucks “few” features. Unfortunately it is a plug-in for Eclipse platform and you have to install many dependencies to get it working.

Mar 3
Color Scheme Generator for Charts
icon1 Seweryn Niemiec | icon2 | icon4 03 3rd, 2007| icon31 Comment »

Sometimes one needs to show many data series on one chart. In such cases, usually distinction between those data series is achieved by using different colors for each data set. Most charting libraries leave colors selection to developer. This can be problem when there is need to choose more than six colors which can be easily distinguished by most people. Below you can find Python program which can be helpful.

Read the rest of this entry »

Oct 20

Few hints for those, who want to run JBoss Cache in clustered mode ([a]synchronous replication/invalidation) on Linux machine with multiple network interface cards (NICs) and using UDP/multicasting in OSI layers 4/3 . Here is situation overview:

We need multicast communication through eth1 to other JBoss Cache nodes.

Read the rest of this entry »

Oct 17
Cisco MIBs horror
icon1 Seweryn Niemiec | icon2 | icon4 10 17th, 2006| icon31 Comment »

Suppose you want to know what vlans are configured/allowed on individual ports in one of recent Cisco Catalyst switches – quite basic information. SNMP seems to be right protocol for this task. Structure of most Catalyst switches can be discovered using ENTITY-MIB and that’s good news. In entPhysicalTable you can find ports, modules, chassis and many other parts with defined relationships between them. Now you want to find vlans for discovered ports and this is where scary part starts. Since port can have many vlans and vice versa, such mapping can be done in SNMP using one column table with row index build by combination of two numbers (portID.vlanID). As value of this row could be:

  • 1 meaning native vlan
  • 2 meaning tagged vlan

Lack of port-vlan combination in table would mean that this port isn’t present in given vlan. Simple? Yes, but too simple for Cisco engineers.

Cisco found another solution. In order to get via SNMP vlans per port information for Cat2950, Cat2970, Cat4500 and Cat6500 (with recent IOSes) you have to correctly combine following tables:

ifTable from IF-MIB
entPhysicalTable from ENTITY-MIB,
entAliasMappingTable from ENTITY-MIB,
vtpVlanTable from CISCO-VTP-MIB,
vlanTrunkPortTable from CISCO-VTP-MIB,
vmMembershipSummaryTable from CISCO-VLAN-MEMBERSHIP-MIB,
dot1dBasePortTable from BRIDGE-MIB

Some of those tables are 3D, have thousands of columns (one bit per column) and all of them use different, non-continuous indexes. But that would be still to easy. To get mapping from ports in vmMembershipSummaryTable to ports in ifTable you have to query dot1dBasePortTable using separate SNMP community for every vlan.

Next Entries »