Wednesday, November 28, 2007

Java

Install on Ubuntu.

Main install:
"sudo aptitude install sun-java5-jdk"
Set up Sun's JVM as default:
"sudo update-java-alternatives -s java-1.5.0-sun" or "sudo gedit /etc/jvm"

For eXo java/jdk1.5
Set up system environments for java snd maven within your home dir .profile file
==========
export JAVA_HOME=/home/alexey/java/jdk1.5
export MAVEN_HOME=/home/alexey/java/maven2
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
==========
Links official and not official


Here some usefull java code pieces would be posted.

Collection to Array:
vector -> string array
String[] strArray = vector.toArray(new String [vector.size()]);
list -> string array
String[] strArray = list.toArray(new String [list.size()]);
etc.


Array to Collection:
vector = Arrays.asList(strArray);

Enumeration to Collection
return Collections.list(returnedEnumeration);

Collection to Enumeration
return Collections.enumeration(returnedColection);

How to return Collection
Collection v = new ArrayList();
v.add(...);
return v;


How to return Enumeration
public Enumeration<string> getProperties(String s) {
// creating typified
Vector<string> result = new Vector<string>();
// fill with sample string
result.add("Hello");
// make return statement
return result.elements();
}


How get InputSource from org.w3c.dom.Document?
(link)
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerFactory;

Document doc = ... // your existing DOM document
DOMSource source = new DOMSource(doc);
StringWriter xmlAsWriter = new StringWriter();
StreamResult result = new StreamResult(xmlAsWriter);
TransformerFactory.newInstance().newTransformer().transform(source, result);
StringReader xmlReader = new StringReader(xmlAsWriter.toString());
InputSource viola = new InputSource(xmlReader);



Read and write line in file
---------------------------
BufferedReader in;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("c:\\in.xml")));
while (in.ready()) {
String s = in.readLine();
System.out.println(s);
}
} catch (IOException e) {
}
---------------------------
try {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("c:\\out.xml",true)));
out.write("hello");
out.newLine();
out.write("test");
out.close();
} catch (IOException e) {
}
---------------------------


Print Exception to print stream (ex.: PrintWriter w = renderResponse.getWriter();)
(new Exception()).printStackTrace(w);
or
StackTraceElement[] ste = Thread.currentThread().getStackTrace();

URL
-
java.net.URL
official
это частный случай java.net.URI official
Example:
url = http://localhost:8080/portal/portal/?portal:componentId=producer1-1556486924@portlets/HelloWorld
protocol http
host localhost
port 8080
getAuthority localhost:8080
getPath /portal/portal/
getQuery portal:componentId=producer1-1556486924@portlets/HelloWorld
getFile /portal/portal/?portal:componentId=producer1-1556486924@portlets/HelloWorld
toExternalForm http://localhost:8080/portal/portal/?portal:componentId=producer1-1556486924@portlets/HelloWorld
getRef null

HttpServletRequest
request.getContextPath() = /portal
request.getServletPath() = /portal/
request.getServerName() = localhost
request.getRequestURL() = http://localhost:8080/portal/portal/
request.getRequestURI() = /portal/portal/

ArrayList converting
Converter applet
Conversion table for Java 1.5+

Ubuntu for developers

Other my posts:
Maven for Eclipse
Tomcat for Eclipse
Subversive for Eclipse

Install JDK

howto jdk on ubuntu wiki
sudo aptitude install sun-java5-jdk
update-alternatives --config java


In your home directory within .profile file add lines with changes according your path:
export JAVA_HOME=/home/alexey/java/jdk1.5
export PATH=$JAVA_HOME/bin:$PATH

SmartSVN
Download page
Screenshots
Direct link 3.0.4 !
License for 1 month
how-to-installsetup-smartsvn-in-ubuntu

Picture1: info
Picture2: working
Picture3: add ignore
(Project -> Settings ...)
Note: window resizing on compiz bug


Eclipse
Web Tools Platform All-In-One Package:
Download page(ver. R-2.0-200706260303)
Download direct link(ver. R-2.0-200706260303) !

Picture1: starting
Picture2: info
Picture3: working

Configure Eclipse it at "Window" -> "Preferences..."

Setting formatter:
Java -> Code Style -> Formatter
Choose: "Edit..." or "Import..." or "Export..."
Example: "Import..." this file

Setting templates:
Java -> Editor -> Templates
Choose: "New..." or "Import..." or "Export..."
e.g.0: "Import..." this file
e.g.1: "Edit..." for sysout: "System.out.println(">>> ${user}: ${enclosing_type}.${enclosing_method} ${word_selection} = " + ${word_selection});${cursor}"
e.g.2: "Edit..." for systrace: System.out.println(">>> ${user}: ${enclosing_type}.${enclosing_method}()");

If Content assist doesnt work by "Ctrl"+"Space", so some application intercepts it. Check for in in SCIM. Right button on and choose "SCIM setup". Edit there hotkeys or keyboard for remove necessary for eclipse hotkeys.

Mark occurrences:
Java -> Editor ->
Mark Occurrences
Check the "
Mark occurrences of the selected element in the current file".


P.S.: If you are developer of eXo Platform then look at screenshot of my working directory (java dir within home on ubuntu)

Wednesday, November 14, 2007

WSRP ABC rhymes

WSRP ABC rhymes

A - is for AxisFilter and for AdminClient ( ... and for me - Alexey)
B - is for BlockingInteractionResponse
C - is for Consumer
D - is for DestroyPortlets
E - is for Event and for Extension
F - is for Fault :(
G - is for GetMarkup and for GetResource
H - is for HandleEvents
I - is for InteractionParams and for ImportPortlets
J - is for JSR286ContainerProxyImpl and for JAXBEventTransformer
K - is for ... [1]
L - is for Lifetime
M - is for Modes and for MarkupContext
N - is for NavigationalContext
O - is for Online and for OperationFailedFault
P - is for Producer and for PortletContext
Q - is for ... [2]
R - is for RegistrationOperationsInterface and for RegistrationContext
S - is for ServiceDescriptionInterface and for SessionContext
T - is for TransientStateManager and for Templates (... and for Tiger as written on my sheet)
U - is for Utils and for UpdateResponse
V - is for ... [3]
W - is for WSRPConsumerPlugin, WSRPStarter and WSRPService
X - is for ... [4]
Y - is for ...
Z - is for ... ( is for Zavizionov)


[1]
No source begins with that letter.
There are only sources containing the letter inside: PortletDescription.getKeywords() and PortletKey
[2]
No source begins with that letter.
The class QName used every where inside wsrp (javax.xml.namespace.QName)
[3]
No source begins with that letter.
ResourceValue
[4]
No source begins with that letter.
eXoPlatform =)

Wednesday, November 7, 2007

Wallpaper

Настало время поменять хорошую, но уже надоевшую обоину на рабочем столе.
"Please don’t hurt the web"

Начал осторожно[1] гуглить со словами "wallpaper 1680 1050"
Наткнулся на неплохой сайт с обоинами http://interfacelift.com/wallpaper/

Закачал несколько обоин, из них выбрал самую понравившуюся и поставил на рабочий стол.
Вот выложил принтскрин в моих фотках или прямой линк на картинку


Вот и всё :)
Пишите комменты, постараюсь ответить.

[1] осторожно - это под влиянием полученного утром письма с темой "Выгуглен". Далее, текст письма:
----------------------------------------------------------------------------
http://www.jetstyle.ru/scroogled/
Замечательная [анти]утопия, имеющая все шансы стать реальным будущим...
И сразу после, еще не утратив послевкусия от прочитанного,
"немедленно, доктор, вот эту штучку" (с) пр. Преображенский
http://www.inosmi.ru/stories/07/04/27/3511/236555.html
----------------------------------------------------------------------------