check/start Oracle listener

If the Oracle listener is running, you’ll get the following message.

$ lsnrctl status

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 04-APR-2009 16:27:02

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.1.0.6.0 - Production
Start Date                29-APR-2009 18:43:13
Uptime                    6 days 21 hr. 43 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.1.0/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.2)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Services Summary...
Service "devdb" has 1 instance(s).
  Instance "devdb", status UNKNOWN, has 1 handler(s) for this service...
Service "devdb.thegeekstuff.com" has 1 instance(s).
  Instance "devdb", status READY, has 1 handler(s) for this service...
Service "devdbXDB.thegeekstuff.com" has 1 instance(s).
  Instance "devdb", status READY, has 1 handler(s) for this service...
Service "devdb_XPT.thegeekstuff.com" has 1 instance(s).
  Instance "devdb", status READY, has 1 handler(s) for this service...
The command completed successfully

start listener:

$ lsnrctl start

Example hibernate mapping xml for one to many by a join table

We have table trade_summary and table trades_comment, each entry in trade_summary has multiple comments in trades_comment table. However, the relationship between these two tables are stored in another join table trade_summary_comment. Each row in trade_summary_comment has two columns: trade_id and comment_id which are primary keys in those two tables. The hibernate mapping goes as follows:

<set name=”comments” table=”trade_summary_comment”>
<key column=”trade_id”/>
<many-to-many column=”comment_id” unique=”true” class=”bmo.hub.idp.entity.TradesComment” order-by=”updated desc”/>
</set>

In java code, we use set in TradeSummary class to store its comments:

private Set<TradesComment> comments = new TreeSet<TradesComment>();

A good post on registerHibernateType

From: http://www.databaseskill.com/498002/

First of all, custom dialect class – Hibernate Dialect class need to inherit the database we use the dialect class. For example: if we use MySQL (version 5.xx), we need to inherit of the org.hibernate dialect. MySQL5Dialect, “; if we are using DB2, then we should inherit” org.hibernate.dialect.DB2Dialect “; And I use SqlServer2008, so I have to inheritance org.hibernate.dialect.SQLServerDialect, the following reference code:

Java code
  1. import java.sql.Types;
  2. import org.hibernate.Hibernate;
  3. import org.hibernate.dialect.SQLServerDialect;
  4. public   class SqlServer2008Dialect extends SQLServerDialect {
  5.      the public SqlServer2008Dialect () {
  6.          super ();
  7. registerHibernateType (Types.CHAR, Hibernate.STRING.getName ());
  8. registerHibernateType (Types.NVARCHAR, Hibernate.STRING.getName ());
  9. registerHibernateType (Types.LONGNVARCHAR, Hibernate.STRING.getName ());
  10. registerHibernateType (Types.DECIMAL, Hibernate.DOUBLE.getName ());
  11. }
  12. }

In short, we can be found in the package of “org.hibernate.dialect” corresponding to the database dialect class. In which we need to pay attention to little:

a, inherits the parent class constructor, the default constructor call “registerHibernateType (int code, String name)” method to the type of data in the database is mapped to the corresponding Java type. code indicates the type of data in the database integer corresponding database types can be found in the the java.sql.Types class. name that we want to map Java type. Found from “org.hibernate.Hibernate”.

b, Types class. Types defined in the database of commonly used field types, such as:

Java code
  1. ……
  2. public   final   static   int a LONGVARCHAR is = – 1;
  3. public   final   static   int TIMESTAMP = 93;
  4. ……

We can “No Dialect mapping for JDBC type:” followed by the number in the class (Types), find the appropriate type.We can also find the appropriate value based on the type of the field in the data table. This value isregisterHibernateType (int code, String name) the first parameter.

c, Hibernate class. The Hibernate defined the purpose of this conversion type, such as shown in the first piece of code. Can be converted into what type, can find in this class. By calling the getName () method to get a String type.Of course, if you remember, we can write

Java code
  1. import org.hibernate.dialect.SQLServerDialect;
  2. public   class SqlServer2008Dialect extends SQLServerDialect {
  3.      the public SqlServer2008Dialect () {
  4.          super ();
  5. registerHibernateType (1, “string”);
  6. registerHibernateType (- 9, “string”);
  7. registerHibernateType (- 16, “string”);
  8. registerHibernateType (3, “double”);
  9. }
  10. }

In fact, is the same as above, but the above represents the value directly write out. O (? _ ?) O haha ??~. Note thatsuper () method call, whether the method is not called an error, I do not know, I have not done this test, so it is best to adjust.

Then, we also need to make changes in the configuration file. I use EJB3, so I added in the META-INF folder under the persistent.xml file property hibernate.dialect “value value xxx.xxx.SqlServer2008Dialect” xxx said the package name, we all know this. The code is as follows:

Java code
  1. <? Xml version = “1.0” encoding = “UTF-8”?>
  2. <Persistence xmlns =
  3. xmlns: xsi =
  4. xsi: schemaLocation = “
  5. version = “1.0”>
  6. <persistence-unit name= “DateSource”>
  7. <jta-data-source> java :/ SqlServerDS </ jta-data-source>
  8. <properties>
  9. <property name= “hibernate.dialect” value= “xxx.xxx.SqlServer2008Dialect” />
  10. <property name= “hibernate.hbm2ddl.auto” value= “none” />
  11. </ Properties>
  12. </ Persistence-unit>
  13. </ Persistence>

Packaged deployment, OK! Of course, if you’re using is Hibernate, you modify the Hibernate configuration file hibernate.cfg.xml changed to their own dialect class “xxx.xxx.SqlServer2008Dialect” can “hibernate.dialect the value of the property.

Set ajax response status code to 401(unauthorized) when the user is not authorized

public @ResponseBody String handleRequest() {

if (null == currentUser) {

return new ResponseEntity<String>(HttpStatus.UNAUTHORIZED);

} else {

// do stuff…

return “blahblah…”;

}

}

In the ajax function, when detect unauthorized header then re-direct to log in page:

if (responseStatus == 401) {

window.location.href=”/login”;

}

A wonderful post on wrapping Spring SecurityContextHolder

From: http://stackoverflow.com/questions/360520/unit-testing-with-spring-security

You are quite right to be concerned – static method calls are particularly problematic for unit testing as you cannot easily mock your dependencies. What I am going to show you is how to let the Spring IoC container do the dirty work for you, leaving you with neat, testable code. SecurityContextHolder is a framework class and while it may be ok for your low-level security code to be tied to it, you probably want to expose a neater interface to your UI components (i.e. controllers).

cliff.meyers mentioned one way around it – create your own “principal” type and inject an instance into consumers. The Spring <aop:scoped-proxy/> tag introduced in 2.x combined with a request scope bean definition, and the factory-method support may be the ticket to the most readable code.

It could work like following:

public class MyUserDetails implements UserDetails {
    // this is your custom UserDetails implementation to serve as a principal
    // implement the Spring methods and add your own methods as appropriate
}

public class MyUserHolder {
    public static MyUserDetails getUserDetails() {
        Authentication a = SecurityContextHolder.getContext().getAuthentication();
        if (a == null) {
            return null;
        } else {
            return (MyUserDetails) a.getPrincipal();
        }
    }
}

public class MyUserAwareController {        
    MyUserDetails currentUser;

    public void setCurrentUser(MyUserDetails currentUser) { 
        this.currentUser = currentUser;
    }

    // controller code
}

Nothing complicated so far, right? In fact you probably had to do most of this already. Next, in your bean context define a request-scoped bean to hold the principal:

<bean id="userDetails" class="MyUserHolder" factory-method="getUserDetails" scope="request">
    <aop:scoped-proxy/>
</bean>

<bean id="controller" class="MyUserAwareController">
    <property name="currentUser" ref="userDetails"/>
    <!-- other props -->
</bean>

Thanks to the magic of the aop:scoped-proxy tag, the static method getUserDetails will be called every time a new HTTP request comes in and any references to the currentUser property will be resolved correctly. Now unit testing becomes trivial:

protected void setUp() {
    // existing init code

    MyUserDetails user = new MyUserDetails();
    // set up user as you wish
    controller.setCurrentUser(user);
}

Hope this helps!

spotfire resources

from: http://spotfire.tibco.com/tips/spotfire-resources/

Spotfire Resources

Spotfire Demo Gallery Features online demos from a variety of industries.
Spotfire Learning Network Many free web-based training courses are available. The full training brochure can be found here.
Quick Reference Topics A large collection of short video tutorials on common topics, with data provided for a hands-on walkthrough.
TIBCO eDelivery This site can be used for downloading any new versions of your Spotfire software.
docs.tibco.com The source for ALL Spotfire product documentation. Downloads for all published docs, including installation and admin manuals for current and prior versions.
System Requirements Lists the system requirements for all products in the Spotfire family
Product Hotfixes Hotfixes can be downloaded here. Sign up for notifications on the TIBCO Support site
Spotfire Datasources An inventory of supported data sources and connectors
Spotfire Cloud Sign up here for a trial of Spotfire Cloud
Tips & Tricks This blog – also includes an archive of past articles.

Community Resources

TIBCOmmunity TIBCO’s central community site. Click here for the Spotfire subcommunity. Includes areas for analysts, admins, and developers.
Spotfire Ideas Covering a wide range of topics from admin to end-user.
Easy Spotfire A collection of IronPython script snippets
Bear on Spotfire Covers a wide range of Spotfire related topics
SpotfireD Unofficial collection of scripts and snippets
Explains Stuff Tim Alexander’s YouTube channel covering Spotfire topics
Trends and Outliers Blog TIBCO’s Spotfire blog covering industry trends