mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
fix line endings in Paparazzi On the Web files
This commit is contained in:
@@ -1,44 +1,44 @@
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin: 0%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 100%;
|
||||
overflow:hidden;
|
||||
max-width:2048px;
|
||||
font-size : 11;
|
||||
}
|
||||
|
||||
select{
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
vertical-align: middle;
|
||||
background-color: #F5F5DC;
|
||||
}
|
||||
input {
|
||||
background-color:#F5F5DC;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#welcome
|
||||
{
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
height:3%;
|
||||
width: 100%;
|
||||
background-color: #EEEEEE;
|
||||
text-align: center;
|
||||
font-weight:bold;
|
||||
font-size : 12;
|
||||
}
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin: 0%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 100%;
|
||||
overflow:hidden;
|
||||
max-width:2048px;
|
||||
font-size : 11;
|
||||
}
|
||||
|
||||
select{
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
vertical-align: middle;
|
||||
background-color: #F5F5DC;
|
||||
}
|
||||
input {
|
||||
background-color:#F5F5DC;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#welcome
|
||||
{
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
height:3%;
|
||||
width: 100%;
|
||||
background-color: #EEEEEE;
|
||||
text-align: center;
|
||||
font-weight:bold;
|
||||
font-size : 12;
|
||||
}
|
||||
#usr
|
||||
{
|
||||
position:absolute;
|
||||
@@ -46,175 +46,175 @@ label {
|
||||
right:6%;
|
||||
height:3%;
|
||||
width:25%;
|
||||
background-color: #EEEEEE;
|
||||
text-align: right;
|
||||
background-color: #EEEEEE;
|
||||
text-align: right;
|
||||
white-space:nowrap;
|
||||
}
|
||||
#page
|
||||
{
|
||||
position:absolute;
|
||||
top:3%;
|
||||
left:0;
|
||||
height:97%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
#choicePanel{
|
||||
position:absolute;
|
||||
top:0%;
|
||||
left:0%;
|
||||
height: 13%;
|
||||
width : 15%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#aircraftSelector
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
#trackdiv
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
-moz-border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-radius: 7px 7px 7px 7px;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-top-left-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-top-right-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-bottom-left-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-bottom-right-radius: 7px; /* pour Chrome */
|
||||
width: 140px;
|
||||
color: white;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
#active_block
|
||||
{
|
||||
font-size:11;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#FlightPlan
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
top:0%;
|
||||
left:15%;
|
||||
height: 40%;
|
||||
width : 14.9%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#FlightParams
|
||||
{
|
||||
position:absolute;
|
||||
top:13%;
|
||||
left :0%
|
||||
text-align: center;
|
||||
height: 27%;
|
||||
width : 14.9%;
|
||||
border: 1px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
#map_canvas
|
||||
{
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:30%;
|
||||
width:70%;
|
||||
}
|
||||
#page
|
||||
{
|
||||
position:absolute;
|
||||
top:3%;
|
||||
left:0;
|
||||
height:97%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
#choicePanel{
|
||||
position:absolute;
|
||||
top:0%;
|
||||
left:0%;
|
||||
height: 13%;
|
||||
width : 15%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#aircraftSelector
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
#trackdiv
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
-moz-border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-radius: 7px 7px 7px 7px;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-top-left-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-top-right-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-bottom-left-radius: 7px; /* pour Chrome */
|
||||
-webkit-border-bottom-right-radius: 7px; /* pour Chrome */
|
||||
width: 140px;
|
||||
color: white;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
#active_block
|
||||
{
|
||||
font-size:11;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#FlightPlan
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
top:0%;
|
||||
left:15%;
|
||||
height: 40%;
|
||||
width : 14.9%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#FlightParams
|
||||
{
|
||||
position:absolute;
|
||||
top:13%;
|
||||
left :0%
|
||||
text-align: center;
|
||||
height: 27%;
|
||||
width : 14.9%;
|
||||
border: 1px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
#map_canvas
|
||||
{
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:30%;
|
||||
width:70%;
|
||||
height: 95%;
|
||||
border:1px solid black;
|
||||
}
|
||||
|
||||
|
||||
#Settings
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
border:1px solid black;
|
||||
}
|
||||
|
||||
|
||||
#Settings
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
left:0%;
|
||||
top:40%;
|
||||
text-align: left;
|
||||
height: 55%;
|
||||
width: 29.9%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#page_setting {
|
||||
|
||||
}
|
||||
|
||||
#setting {
|
||||
width: 400px;
|
||||
height: 250px;
|
||||
padding: 0.5em;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 8;
|
||||
}
|
||||
#param
|
||||
{
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#NewsDiv
|
||||
{
|
||||
position:absolute;
|
||||
overflow:auto;
|
||||
left:0%;
|
||||
top:95%;
|
||||
height: 5%;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
vertical-align:top;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#info
|
||||
{
|
||||
text-align: left;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#Debug
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
left:65%;
|
||||
top:50%;
|
||||
text-align: center;
|
||||
height: 50%;
|
||||
width: 35%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
padding-top:20px;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#title{
|
||||
font-weight:bold;
|
||||
font-size:18;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
table.param {
|
||||
border:3px solid #6495ed;
|
||||
border-collapse:collapse;
|
||||
width:90%;
|
||||
margin:auto;
|
||||
}
|
||||
td.param {
|
||||
font-family:sans-serif;
|
||||
font-size:11px;
|
||||
border:1px solid #6495ed;
|
||||
padding:5px;
|
||||
text-align:left;
|
||||
}
|
||||
top:40%;
|
||||
text-align: left;
|
||||
height: 55%;
|
||||
width: 29.9%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#page_setting {
|
||||
|
||||
}
|
||||
|
||||
#setting {
|
||||
width: 400px;
|
||||
height: 250px;
|
||||
padding: 0.5em;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 8;
|
||||
}
|
||||
#param
|
||||
{
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#NewsDiv
|
||||
{
|
||||
position:absolute;
|
||||
overflow:auto;
|
||||
left:0%;
|
||||
top:95%;
|
||||
height: 5%;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
vertical-align:top;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#info
|
||||
{
|
||||
text-align: left;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#Debug
|
||||
{
|
||||
overflow:auto;
|
||||
position:absolute;
|
||||
left:65%;
|
||||
top:50%;
|
||||
text-align: center;
|
||||
height: 50%;
|
||||
width: 35%;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid black;
|
||||
padding-top:20px;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#title{
|
||||
font-weight:bold;
|
||||
font-size:18;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
table.param {
|
||||
border:3px solid #6495ed;
|
||||
border-collapse:collapse;
|
||||
width:90%;
|
||||
margin:auto;
|
||||
}
|
||||
td.param {
|
||||
font-family:sans-serif;
|
||||
font-size:11px;
|
||||
border:1px solid #6495ed;
|
||||
padding:5px;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
body
|
||||
{
|
||||
width: 90%;
|
||||
margin-top: 5px;
|
||||
body
|
||||
{
|
||||
width: 90%;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left:5%;
|
||||
margin-reight:5%;
|
||||
margin-reight:5%;
|
||||
background-color: #CCFFCC;
|
||||
text-align:justify;
|
||||
text-align:justify;
|
||||
}
|
||||
|
||||
h3,h2
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin-top: 2%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 100%;
|
||||
overflow:hidden;
|
||||
max-width:2048px;
|
||||
text-align:center;
|
||||
font-size:24px;
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin-top: 2%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 100%;
|
||||
overflow:hidden;
|
||||
max-width:2048px;
|
||||
text-align:center;
|
||||
font-size:24px;
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
body
|
||||
{
|
||||
width: 960px;
|
||||
margin-top: 100px;
|
||||
body
|
||||
{
|
||||
width: 960px;
|
||||
margin-top: 100px;
|
||||
margin-bottom: 5px;
|
||||
background-image: url("Icons/logo.png");
|
||||
background-repeat:no-repeat;
|
||||
background-repeat:no-repeat;
|
||||
background-color: #CCFFCC;
|
||||
|
||||
}
|
||||
|
||||
#signIn
|
||||
{
|
||||
margin: auto;
|
||||
width: 300px;
|
||||
height: 140px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#log
|
||||
{
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
a
|
||||
|
||||
}
|
||||
|
||||
#signIn
|
||||
{
|
||||
position:absolute;
|
||||
margin: auto;
|
||||
width: 300px;
|
||||
height: 140px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
#log
|
||||
{
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
position:absolute;
|
||||
right:1%;
|
||||
top:80%;
|
||||
top:80%;
|
||||
}
|
||||
@@ -1,87 +1,87 @@
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin: 0%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 95%;
|
||||
}
|
||||
#page
|
||||
{
|
||||
width: 100%;
|
||||
height: 95%;
|
||||
}
|
||||
|
||||
#logo
|
||||
{
|
||||
width: 960px;
|
||||
height: 100px;
|
||||
background-image: url("banniere.jpg");
|
||||
background-repeat: repeat-x;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#leftmenu
|
||||
{
|
||||
/* float: left; /* Le menu flottera à gauche */
|
||||
/* width: 120px; *//* Très important : donner une taille au menu */
|
||||
}
|
||||
#welcome
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
border: 2px solid black;
|
||||
margin-bottom: 10px; /* Pour éviter que les éléments du menu ne soient trop collés */
|
||||
}
|
||||
#choice
|
||||
{
|
||||
float: left;
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
border: 2px solid black;
|
||||
height: 190px;
|
||||
width: 20px;
|
||||
}
|
||||
#map_canvas
|
||||
{
|
||||
width: 690px;
|
||||
height: 350px;
|
||||
margin-left: 125px;
|
||||
}
|
||||
|
||||
#FlightPlan
|
||||
{
|
||||
float: right;
|
||||
width: 135px; /* Très important : donner une taille au menu */
|
||||
height: 345px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ControlPanel
|
||||
{
|
||||
float: left;
|
||||
text-align: center;
|
||||
height: 150px;
|
||||
width: 600px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
#FlightParams
|
||||
{
|
||||
text-align: center;
|
||||
float: right;
|
||||
height: 150px;
|
||||
width: 350px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
table
|
||||
{
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
background-color: #CCFFCC;
|
||||
margin: 0%;
|
||||
padding: 0%;
|
||||
outline: 0%;
|
||||
height: 95%;
|
||||
}
|
||||
#page
|
||||
{
|
||||
width: 100%;
|
||||
height: 95%;
|
||||
}
|
||||
|
||||
#logo
|
||||
{
|
||||
width: 960px;
|
||||
height: 100px;
|
||||
background-image: url("banniere.jpg");
|
||||
background-repeat: repeat-x;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#leftmenu
|
||||
{
|
||||
/* float: left; /* Le menu flottera à gauche */
|
||||
/* width: 120px; *//* Très important : donner une taille au menu */
|
||||
}
|
||||
#welcome
|
||||
{
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
border: 2px solid black;
|
||||
margin-bottom: 10px; /* Pour éviter que les éléments du menu ne soient trop collés */
|
||||
}
|
||||
#choice
|
||||
{
|
||||
float: left;
|
||||
text-align: center;
|
||||
background-color: #EEEEEE;
|
||||
border: 2px solid black;
|
||||
height: 190px;
|
||||
width: 20px;
|
||||
}
|
||||
#map_canvas
|
||||
{
|
||||
width: 690px;
|
||||
height: 350px;
|
||||
margin-left: 125px;
|
||||
}
|
||||
|
||||
#FlightPlan
|
||||
{
|
||||
float: right;
|
||||
width: 135px; /* Très important : donner une taille au menu */
|
||||
height: 345px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ControlPanel
|
||||
{
|
||||
float: left;
|
||||
text-align: center;
|
||||
height: 150px;
|
||||
width: 600px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
#FlightParams
|
||||
{
|
||||
text-align: center;
|
||||
float: right;
|
||||
height: 150px;
|
||||
width: 350px;
|
||||
border: 2px solid black;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
table
|
||||
{
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*--------------------------------------------------|
|
||||
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|
||||
|---------------------------------------------------|
|
||||
| Copyright (c) 2002-2003 Geir Landrö |
|
||||
|--------------------------------------------------*/
|
||||
|
||||
.dtree {
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dtree img {
|
||||
border: 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dtree a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
.dtree a.node, .dtree a.nodeSel {
|
||||
white-space: nowrap;
|
||||
padding: 1px 2px 1px 2px;
|
||||
}
|
||||
.dtree a.node:hover, .dtree a.nodeSel:hover {
|
||||
color: #333;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.dtree a.nodeSel {
|
||||
background-color: #c0d2ec;
|
||||
}
|
||||
.dtree .clip {
|
||||
overflow: hidden;
|
||||
/*--------------------------------------------------|
|
||||
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|
||||
|---------------------------------------------------|
|
||||
| Copyright (c) 2002-2003 Geir Landrö |
|
||||
|--------------------------------------------------*/
|
||||
|
||||
.dtree {
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dtree img {
|
||||
border: 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dtree a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
.dtree a.node, .dtree a.nodeSel {
|
||||
white-space: nowrap;
|
||||
padding: 1px 2px 1px 2px;
|
||||
}
|
||||
.dtree a.node:hover, .dtree a.nodeSel:hover {
|
||||
color: #333;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.dtree a.nodeSel {
|
||||
background-color: #c0d2ec;
|
||||
}
|
||||
.dtree .clip {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<conf_pow author="genin">
|
||||
<portIvyToWeb>8535</portIvyToWeb>
|
||||
<portWebToIvy>8536</portWebToIvy>
|
||||
<sizeUdpTrame>1024</sizeUdpTrame>
|
||||
<udpSocketTimeout>10000</udpSocketTimeout>
|
||||
<dataBaseName>pow_sql</dataBaseName>
|
||||
<enableDatabase>true</enableDatabase><dbMode>silent</dbMode><dbUserName>pow_user</dbUserName>
|
||||
<dbPassword>pwdpow_user</dbPassword>
|
||||
<webAdminLogin>admin</webAdminLogin>
|
||||
<mailWebAdmin>admin@pow.fr</mailWebAdmin>
|
||||
<!--configuration for ivy client--><!-- period of time in millisec to reset the filter of waypoint_moved messages -->
|
||||
<time2resetFilter>1200000</time2resetFilter>
|
||||
<!-- period of time in millisec to send all the parameter values for a specific drone-->
|
||||
<timeToSendValues>60000</timeToSendValues>
|
||||
<!-- timeout in interface -->
|
||||
<!-- time to wait for the acknowledgement of an order -->
|
||||
<order_response_timeout>10000</order_response_timeout>
|
||||
<!-- time to wait after a die event to remove the drone -->
|
||||
<dieEventTimeoutTime>5000</dieEventTimeoutTime>
|
||||
<!-- time to wait after receiving no data for a drone to remove the drone -->
|
||||
<dataEventTimeoutTime>30000</dataEventTimeoutTime>
|
||||
<!--period of time to check for dead ivy buses in serveur thread--><time2checkDeadBuses>30000</time2checkDeadBuses>
|
||||
</conf_pow>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<conf_pow author="genin">
|
||||
<portIvyToWeb>8535</portIvyToWeb>
|
||||
<portWebToIvy>8536</portWebToIvy>
|
||||
<sizeUdpTrame>1024</sizeUdpTrame>
|
||||
<udpSocketTimeout>10000</udpSocketTimeout>
|
||||
<dataBaseName>pow_sql</dataBaseName>
|
||||
<enableDatabase>true</enableDatabase><dbMode>silent</dbMode><dbUserName>pow_user</dbUserName>
|
||||
<dbPassword>pwdpow_user</dbPassword>
|
||||
<webAdminLogin>admin</webAdminLogin>
|
||||
<mailWebAdmin>admin@pow.fr</mailWebAdmin>
|
||||
<!--configuration for ivy client--><!-- period of time in millisec to reset the filter of waypoint_moved messages -->
|
||||
<time2resetFilter>1200000</time2resetFilter>
|
||||
<!-- period of time in millisec to send all the parameter values for a specific drone-->
|
||||
<timeToSendValues>60000</timeToSendValues>
|
||||
<!-- timeout in interface -->
|
||||
<!-- time to wait for the acknowledgement of an order -->
|
||||
<order_response_timeout>10000</order_response_timeout>
|
||||
<!-- time to wait after a die event to remove the drone -->
|
||||
<dieEventTimeoutTime>5000</dieEventTimeoutTime>
|
||||
<!-- time to wait after receiving no data for a drone to remove the drone -->
|
||||
<dataEventTimeoutTime>30000</dataEventTimeoutTime>
|
||||
<!--period of time to check for dead ivy buses in serveur thread--><time2checkDeadBuses>30000</time2checkDeadBuses>
|
||||
</conf_pow>
|
||||
|
||||
+24
-24
@@ -1,24 +1,24 @@
|
||||
function DOMImplementation(sUrl, fCallback) {
|
||||
var dom;
|
||||
if(window.ActiveXObject) {
|
||||
dom = new ActiveXObject("Microsoft.XMLDOM");
|
||||
dom.onreadystatechange = function() {
|
||||
if(dom.readyState == 4) {
|
||||
//alert("win "+sUrl+" loaded");
|
||||
fCallback(dom);
|
||||
}
|
||||
};
|
||||
}
|
||||
else if(document.implementation && document.implementation.createDocument) {
|
||||
dom = document.implementation.createDocument("", "", null);
|
||||
dom.onload = function() {
|
||||
//alert("other "+sUrl+" loaded");
|
||||
fCallback(dom);
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert("Votre navigateur ne gère pas l'importation de fichiers XML");
|
||||
return;
|
||||
}
|
||||
dom.load(sUrl);
|
||||
}
|
||||
function DOMImplementation(sUrl, fCallback) {
|
||||
var dom;
|
||||
if(window.ActiveXObject) {
|
||||
dom = new ActiveXObject("Microsoft.XMLDOM");
|
||||
dom.onreadystatechange = function() {
|
||||
if(dom.readyState == 4) {
|
||||
//alert("win "+sUrl+" loaded");
|
||||
fCallback(dom);
|
||||
}
|
||||
};
|
||||
}
|
||||
else if(document.implementation && document.implementation.createDocument) {
|
||||
dom = document.implementation.createDocument("", "", null);
|
||||
dom.onload = function() {
|
||||
//alert("other "+sUrl+" loaded");
|
||||
fCallback(dom);
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert("Votre navigateur ne gère pas l'importation de fichiers XML");
|
||||
return;
|
||||
}
|
||||
dom.load(sUrl);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
function getXMLHttpRequest() {
|
||||
var xhr = null;
|
||||
|
||||
if (window.XMLHttpRequest || window.ActiveXObject) {
|
||||
if (window.ActiveXObject) {
|
||||
try {
|
||||
xhr = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch(e) {
|
||||
xhr = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
} else {
|
||||
xhr = new XMLHttpRequest();
|
||||
}
|
||||
} else {
|
||||
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
|
||||
return null;
|
||||
}
|
||||
|
||||
return xhr;
|
||||
}
|
||||
function getXMLHttpRequest() {
|
||||
var xhr = null;
|
||||
|
||||
if (window.XMLHttpRequest || window.ActiveXObject) {
|
||||
if (window.ActiveXObject) {
|
||||
try {
|
||||
xhr = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch(e) {
|
||||
xhr = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
} else {
|
||||
xhr = new XMLHttpRequest();
|
||||
}
|
||||
} else {
|
||||
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
|
||||
return null;
|
||||
}
|
||||
|
||||
return xhr;
|
||||
}
|
||||
|
||||
@@ -1,97 +1,97 @@
|
||||
// Browser Detect Lite v2.1.4
|
||||
// http://www.dithered.com/javascript/browser_detect/index.html
|
||||
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
|
||||
|
||||
|
||||
function BrowserDetectLite() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
|
||||
// browser name
|
||||
this.isGecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
|
||||
this.isMozilla = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
|
||||
this.isNS = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
|
||||
this.isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) );
|
||||
this.isSafari = (ua.indexOf('safari') != - 1);
|
||||
this.isOpera = (ua.indexOf('opera') != -1);
|
||||
this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari);
|
||||
this.isIcab = (ua.indexOf('icab') != -1);
|
||||
this.isAol = (ua.indexOf('aol') != -1);
|
||||
|
||||
// spoofing and compatible browsers
|
||||
this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
|
||||
this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
|
||||
|
||||
// browser version
|
||||
this.versionMinor = parseFloat(navigator.appVersion);
|
||||
|
||||
// correct version number
|
||||
if (this.isNS && this.isGecko) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isIE && this.versionMinor >= 4) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
|
||||
}
|
||||
else if (this.isMozilla) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
|
||||
}
|
||||
else if (this.isSafari) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isOpera) {
|
||||
if (ua.indexOf('opera/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
|
||||
}
|
||||
}
|
||||
else if (this.isKonqueror) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
|
||||
}
|
||||
else if (this.isIcab) {
|
||||
if (ua.indexOf('icab/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.versionMajor = parseInt(this.versionMinor);
|
||||
this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
|
||||
|
||||
// dom support
|
||||
this.isDOM1 = (document.getElementById);
|
||||
this.isDOM2Event = (document.addEventListener && document.removeEventListener);
|
||||
|
||||
// css compatibility mode
|
||||
this.mode = document.compatMode ? document.compatMode : 'BackCompat';
|
||||
|
||||
// platform
|
||||
this.isWin = (ua.indexOf('win') != -1);
|
||||
this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
|
||||
this.isMac = (ua.indexOf('mac') != -1);
|
||||
this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
|
||||
this.isLinux = (ua.indexOf('linux') != -1);
|
||||
|
||||
// specific browser shortcuts
|
||||
this.isNS4x = (this.isNS && this.versionMajor == 4);
|
||||
this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
|
||||
this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
|
||||
this.isNS4up = (this.isNS && this.versionMinor >= 4);
|
||||
this.isNS6x = (this.isNS && this.versionMajor == 6);
|
||||
this.isNS6up = (this.isNS && this.versionMajor >= 6);
|
||||
this.isNS7x = (this.isNS && this.versionMajor == 7);
|
||||
this.isNS7up = (this.isNS && this.versionMajor >= 7);
|
||||
|
||||
this.isIE4x = (this.isIE && this.versionMajor == 4);
|
||||
this.isIE4up = (this.isIE && this.versionMajor >= 4);
|
||||
this.isIE5x = (this.isIE && this.versionMajor == 5);
|
||||
this.isIE55 = (this.isIE && this.versionMinor == 5.5);
|
||||
this.isIE5up = (this.isIE && this.versionMajor >= 5);
|
||||
this.isIE6x = (this.isIE && this.versionMajor == 6);
|
||||
this.isIE6up = (this.isIE && this.versionMajor >= 6);
|
||||
|
||||
this.isIE4xMac = (this.isIE4x && this.isMac);
|
||||
}
|
||||
var browser = new BrowserDetectLite();
|
||||
// Browser Detect Lite v2.1.4
|
||||
// http://www.dithered.com/javascript/browser_detect/index.html
|
||||
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
|
||||
|
||||
|
||||
function BrowserDetectLite() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
|
||||
// browser name
|
||||
this.isGecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
|
||||
this.isMozilla = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
|
||||
this.isNS = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
|
||||
this.isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) );
|
||||
this.isSafari = (ua.indexOf('safari') != - 1);
|
||||
this.isOpera = (ua.indexOf('opera') != -1);
|
||||
this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari);
|
||||
this.isIcab = (ua.indexOf('icab') != -1);
|
||||
this.isAol = (ua.indexOf('aol') != -1);
|
||||
|
||||
// spoofing and compatible browsers
|
||||
this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
|
||||
this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
|
||||
|
||||
// browser version
|
||||
this.versionMinor = parseFloat(navigator.appVersion);
|
||||
|
||||
// correct version number
|
||||
if (this.isNS && this.isGecko) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isIE && this.versionMinor >= 4) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
|
||||
}
|
||||
else if (this.isMozilla) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
|
||||
}
|
||||
else if (this.isSafari) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isOpera) {
|
||||
if (ua.indexOf('opera/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
|
||||
}
|
||||
}
|
||||
else if (this.isKonqueror) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
|
||||
}
|
||||
else if (this.isIcab) {
|
||||
if (ua.indexOf('icab/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.versionMajor = parseInt(this.versionMinor);
|
||||
this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
|
||||
|
||||
// dom support
|
||||
this.isDOM1 = (document.getElementById);
|
||||
this.isDOM2Event = (document.addEventListener && document.removeEventListener);
|
||||
|
||||
// css compatibility mode
|
||||
this.mode = document.compatMode ? document.compatMode : 'BackCompat';
|
||||
|
||||
// platform
|
||||
this.isWin = (ua.indexOf('win') != -1);
|
||||
this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
|
||||
this.isMac = (ua.indexOf('mac') != -1);
|
||||
this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
|
||||
this.isLinux = (ua.indexOf('linux') != -1);
|
||||
|
||||
// specific browser shortcuts
|
||||
this.isNS4x = (this.isNS && this.versionMajor == 4);
|
||||
this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
|
||||
this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
|
||||
this.isNS4up = (this.isNS && this.versionMinor >= 4);
|
||||
this.isNS6x = (this.isNS && this.versionMajor == 6);
|
||||
this.isNS6up = (this.isNS && this.versionMajor >= 6);
|
||||
this.isNS7x = (this.isNS && this.versionMajor == 7);
|
||||
this.isNS7up = (this.isNS && this.versionMajor >= 7);
|
||||
|
||||
this.isIE4x = (this.isIE && this.versionMajor == 4);
|
||||
this.isIE4up = (this.isIE && this.versionMajor >= 4);
|
||||
this.isIE5x = (this.isIE && this.versionMajor == 5);
|
||||
this.isIE55 = (this.isIE && this.versionMinor == 5.5);
|
||||
this.isIE5up = (this.isIE && this.versionMajor >= 5);
|
||||
this.isIE6x = (this.isIE && this.versionMajor == 6);
|
||||
this.isIE6up = (this.isIE && this.versionMajor >= 6);
|
||||
|
||||
this.isIE4xMac = (this.isIE4x && this.isMac);
|
||||
}
|
||||
var browser = new BrowserDetectLite();
|
||||
|
||||
@@ -1,155 +1,155 @@
|
||||
/*
|
||||
Author : bieler batiste
|
||||
Company : doSimple : http://www.dosimple.ch
|
||||
send me a mail for more informations : faden@PASDEPOURRIELaltern.org - remove ( PASDEPOURRIEL )
|
||||
|
||||
Short javascript function to create and handle a CSS navigation menu
|
||||
|
||||
Copyright (C) 2004 Bieler Batiste
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// the timeout for the menu
|
||||
var timeout = 100;
|
||||
|
||||
// not very clean but simple
|
||||
// the function can be run in the HTML for faster display
|
||||
// window.onload=initMenu;
|
||||
|
||||
// creat timeout variables for list item
|
||||
// it's for avoid some warning with IE
|
||||
for( var i = 0; i < 100; i++ )
|
||||
{
|
||||
eval("var timeoutli" + i + " = false;");
|
||||
}
|
||||
|
||||
// this fonction apply the CSS style and the event
|
||||
function initMenu()
|
||||
{
|
||||
// a test to avoid some browser like IE4, Opera 6, and IE Mac
|
||||
if ( browser.isDOM1
|
||||
&& !( browser.isMac && browser.isIE )
|
||||
&& !( browser.isOpera && browser.versionMajor < 7 )
|
||||
&& !( browser.isIE && browser.versionMajor < 5 ) )
|
||||
{
|
||||
// get some element
|
||||
var menu = document.getElementById('menu'); // the root element
|
||||
var lis = menu.getElementsByTagName('li'); // all the li
|
||||
|
||||
// change the class name of the menu,
|
||||
// it's usefull for compatibility with old browser
|
||||
menu.className='menu';
|
||||
// i am searching for ul element in li element
|
||||
for ( var i=0; i<lis.length; i++ )
|
||||
{
|
||||
// is there a ul element ?
|
||||
if ( lis.item(i).getElementsByTagName('ul').length > 0 )
|
||||
{
|
||||
// improve IE key navigation
|
||||
if ( browser.isIE )
|
||||
{
|
||||
addAnEvent(lis.item(i),'keyup',show);
|
||||
}
|
||||
// link events to list item
|
||||
addAnEvent(lis.item(i),'mouseover',show);
|
||||
addAnEvent(lis.item(i),'mouseout',timeoutHide);
|
||||
addAnEvent(lis.item(i),'blur',timeoutHide);
|
||||
addAnEvent(lis.item(i),'focus',show);
|
||||
|
||||
// add an id to list item
|
||||
lis.item(i).setAttribute( 'id', "li"+i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Author : bieler batiste
|
||||
Company : doSimple : http://www.dosimple.ch
|
||||
send me a mail for more informations : faden@PASDEPOURRIELaltern.org - remove ( PASDEPOURRIEL )
|
||||
|
||||
|
||||
Short javascript function to create and handle a CSS navigation menu
|
||||
|
||||
|
||||
function addAnEvent( target, eventName, functionName )
|
||||
{
|
||||
// apply the method to IE
|
||||
if ( browser.isIE )
|
||||
{
|
||||
//attachEvent dont work properly with this
|
||||
eval('target.on'+eventName+'=functionName');
|
||||
}
|
||||
// apply the method to DOM compliant browsers
|
||||
else
|
||||
{
|
||||
target.addEventListener( eventName , functionName , true ); // true is important for Opera7
|
||||
}
|
||||
}
|
||||
|
||||
// hide the first ul element of the current element
|
||||
function timeoutHide()
|
||||
{
|
||||
// start the timeout
|
||||
eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
|
||||
}
|
||||
|
||||
// hide the ul elements under the element identified by id
|
||||
function hideUlUnder( id )
|
||||
{
|
||||
document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
|
||||
}
|
||||
|
||||
// show the first ul element found under this element
|
||||
function show()
|
||||
{
|
||||
// show the sub menu
|
||||
this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
|
||||
var currentNode=this;
|
||||
while(currentNode)
|
||||
{
|
||||
if( currentNode.nodeName=='LI')
|
||||
{
|
||||
// currentNode.getElementsByTagName('a')[0].className = 'linkOver';
|
||||
}
|
||||
currentNode=currentNode.parentNode;
|
||||
}
|
||||
// clear the timeout
|
||||
eval ( "clearTimeout( timeout"+ this.id +");" );
|
||||
hideAllOthersUls( this );
|
||||
}
|
||||
|
||||
// hide all ul on the same level of this list item
|
||||
function hideAllOthersUls( currentLi )
|
||||
{
|
||||
var lis = currentLi.parentNode;
|
||||
for ( var i=0; i<lis.childNodes.length; i++ )
|
||||
{
|
||||
if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
|
||||
{
|
||||
hideUlUnderLi( lis.childNodes[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hide all the ul wich are in the li element
|
||||
function hideUlUnderLi( li )
|
||||
{
|
||||
var as = li.getElementsByTagName('a');
|
||||
for ( var i=0; i<as.length; i++ )
|
||||
{
|
||||
as.item(i).className="";
|
||||
}
|
||||
var uls = li.getElementsByTagName('ul');
|
||||
for ( var i=0; i<uls.length; i++ )
|
||||
{
|
||||
uls.item(i).style['visibility'] = 'hidden';
|
||||
}
|
||||
}
|
||||
Copyright (C) 2004 Bieler Batiste
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// the timeout for the menu
|
||||
var timeout = 100;
|
||||
|
||||
// not very clean but simple
|
||||
// the function can be run in the HTML for faster display
|
||||
// window.onload=initMenu;
|
||||
|
||||
// creat timeout variables for list item
|
||||
// it's for avoid some warning with IE
|
||||
for( var i = 0; i < 100; i++ )
|
||||
{
|
||||
eval("var timeoutli" + i + " = false;");
|
||||
}
|
||||
|
||||
// this fonction apply the CSS style and the event
|
||||
function initMenu()
|
||||
{
|
||||
// a test to avoid some browser like IE4, Opera 6, and IE Mac
|
||||
if ( browser.isDOM1
|
||||
&& !( browser.isMac && browser.isIE )
|
||||
&& !( browser.isOpera && browser.versionMajor < 7 )
|
||||
&& !( browser.isIE && browser.versionMajor < 5 ) )
|
||||
{
|
||||
// get some element
|
||||
var menu = document.getElementById('menu'); // the root element
|
||||
var lis = menu.getElementsByTagName('li'); // all the li
|
||||
|
||||
// change the class name of the menu,
|
||||
// it's usefull for compatibility with old browser
|
||||
menu.className='menu';
|
||||
// i am searching for ul element in li element
|
||||
for ( var i=0; i<lis.length; i++ )
|
||||
{
|
||||
// is there a ul element ?
|
||||
if ( lis.item(i).getElementsByTagName('ul').length > 0 )
|
||||
{
|
||||
// improve IE key navigation
|
||||
if ( browser.isIE )
|
||||
{
|
||||
addAnEvent(lis.item(i),'keyup',show);
|
||||
}
|
||||
// link events to list item
|
||||
addAnEvent(lis.item(i),'mouseover',show);
|
||||
addAnEvent(lis.item(i),'mouseout',timeoutHide);
|
||||
addAnEvent(lis.item(i),'blur',timeoutHide);
|
||||
addAnEvent(lis.item(i),'focus',show);
|
||||
|
||||
// add an id to list item
|
||||
lis.item(i).setAttribute( 'id', "li"+i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function addAnEvent( target, eventName, functionName )
|
||||
{
|
||||
// apply the method to IE
|
||||
if ( browser.isIE )
|
||||
{
|
||||
//attachEvent dont work properly with this
|
||||
eval('target.on'+eventName+'=functionName');
|
||||
}
|
||||
// apply the method to DOM compliant browsers
|
||||
else
|
||||
{
|
||||
target.addEventListener( eventName , functionName , true ); // true is important for Opera7
|
||||
}
|
||||
}
|
||||
|
||||
// hide the first ul element of the current element
|
||||
function timeoutHide()
|
||||
{
|
||||
// start the timeout
|
||||
eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
|
||||
}
|
||||
|
||||
// hide the ul elements under the element identified by id
|
||||
function hideUlUnder( id )
|
||||
{
|
||||
document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
|
||||
}
|
||||
|
||||
// show the first ul element found under this element
|
||||
function show()
|
||||
{
|
||||
// show the sub menu
|
||||
this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
|
||||
var currentNode=this;
|
||||
while(currentNode)
|
||||
{
|
||||
if( currentNode.nodeName=='LI')
|
||||
{
|
||||
// currentNode.getElementsByTagName('a')[0].className = 'linkOver';
|
||||
}
|
||||
currentNode=currentNode.parentNode;
|
||||
}
|
||||
// clear the timeout
|
||||
eval ( "clearTimeout( timeout"+ this.id +");" );
|
||||
hideAllOthersUls( this );
|
||||
}
|
||||
|
||||
// hide all ul on the same level of this list item
|
||||
function hideAllOthersUls( currentLi )
|
||||
{
|
||||
var lis = currentLi.parentNode;
|
||||
for ( var i=0; i<lis.childNodes.length; i++ )
|
||||
{
|
||||
if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
|
||||
{
|
||||
hideUlUnderLi( lis.childNodes[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hide all the ul wich are in the li element
|
||||
function hideUlUnderLi( li )
|
||||
{
|
||||
var as = li.getElementsByTagName('a');
|
||||
for ( var i=0; i<as.length; i++ )
|
||||
{
|
||||
as.item(i).className="";
|
||||
}
|
||||
var uls = li.getElementsByTagName('ul');
|
||||
for ( var i=0; i<uls.length; i++ )
|
||||
{
|
||||
uls.item(i).style['visibility'] = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +1,110 @@
|
||||
var timeout = 100;
|
||||
var timeout = 100;
|
||||
|
||||
for( var i = 0; i < 100; i++ )
|
||||
{
|
||||
eval("var timeoutli" + i + " = false;");
|
||||
for( var i = 0; i < 100; i++ )
|
||||
{
|
||||
eval("var timeoutli" + i + " = false;");
|
||||
}
|
||||
|
||||
|
||||
function initMenu2(){
|
||||
if ( browser.isDOM1
|
||||
&& !( browser.isMac && browser.isIE )
|
||||
&& !( browser.isOpera && browser.versionMajor < 7 )
|
||||
&& !( browser.isIE && browser.versionMajor < 5 ) )
|
||||
if ( browser.isDOM1
|
||||
&& !( browser.isMac && browser.isIE )
|
||||
&& !( browser.isOpera && browser.versionMajor < 7 )
|
||||
&& !( browser.isIE && browser.versionMajor < 5 ) )
|
||||
{
|
||||
var menu2 = document.getElementById('menu2');
|
||||
var lis2 = menu2.getElementsByTagName('li');
|
||||
|
||||
menu2.className='menu2';
|
||||
for ( var i=0; i<lis2.length; i++ )
|
||||
{
|
||||
|
||||
if ( lis2.item(i).getElementsByTagName('ul').length > 0 )
|
||||
menu2.className='menu2';
|
||||
for ( var i=0; i<lis2.length; i++ )
|
||||
{
|
||||
|
||||
if ( lis2.item(i).getElementsByTagName('ul').length > 0 )
|
||||
{
|
||||
if ( browser.isIE )
|
||||
{
|
||||
addAnEvent(lis2.item(i),'keyup',show);
|
||||
}
|
||||
|
||||
addAnEvent(lis2.item(i),'mouseover',show);
|
||||
addAnEvent(lis2.item(i),'mouseout',timeoutHide);
|
||||
addAnEvent(lis2.item(i),'blur',timeoutHide);
|
||||
addAnEvent(lis2.item(i),'focus',show);
|
||||
|
||||
lis2.item(i).setAttribute( 'id', "li2"+i );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( browser.isIE )
|
||||
{
|
||||
addAnEvent(lis2.item(i),'keyup',show);
|
||||
}
|
||||
|
||||
addAnEvent(lis2.item(i),'mouseover',show);
|
||||
addAnEvent(lis2.item(i),'mouseout',timeoutHide);
|
||||
addAnEvent(lis2.item(i),'blur',timeoutHide);
|
||||
addAnEvent(lis2.item(i),'focus',show);
|
||||
|
||||
lis2.item(i).setAttribute( 'id', "li2"+i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addAnEvent( target, eventName, functionName )
|
||||
|
||||
function addAnEvent( target, eventName, functionName )
|
||||
{
|
||||
if ( browser.isIE )
|
||||
if ( browser.isIE )
|
||||
{
|
||||
eval('target.on'+eventName+'=functionName');
|
||||
}
|
||||
else
|
||||
{
|
||||
eval('target.on'+eventName+'=functionName');
|
||||
}
|
||||
else
|
||||
{
|
||||
target.addEventListener( eventName , functionName , true );
|
||||
}
|
||||
}
|
||||
|
||||
function timeoutHide()
|
||||
}
|
||||
}
|
||||
|
||||
function timeoutHide()
|
||||
{
|
||||
eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
|
||||
}
|
||||
|
||||
// hide the ul elements under the element identified by id
|
||||
function hideUlUnder( id )
|
||||
{
|
||||
document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
|
||||
}
|
||||
|
||||
// show the first ul element found under this element
|
||||
function show()
|
||||
{
|
||||
// show the sub menu
|
||||
this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
|
||||
var currentNode=this;
|
||||
while(currentNode)
|
||||
{
|
||||
if( currentNode.nodeName=='LI')
|
||||
{
|
||||
// currentNode.getElementsByTagName('a')[0].className = 'linkOver';
|
||||
}
|
||||
currentNode=currentNode.parentNode;
|
||||
}
|
||||
// clear the timeout
|
||||
eval ( "clearTimeout( timeout"+ this.id +");" );
|
||||
hideAllOthersUls( this );
|
||||
}
|
||||
|
||||
// hide all ul on the same level of this list item
|
||||
function hideAllOthersUls( currentLi )
|
||||
{
|
||||
var lis = currentLi.parentNode;
|
||||
for ( var i=0; i<lis.childNodes.length; i++ )
|
||||
{
|
||||
if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
|
||||
{
|
||||
hideUlUnderLi( lis.childNodes[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hide all the ul wich are in the li element
|
||||
function hideUlUnderLi( li )
|
||||
{
|
||||
var as = li.getElementsByTagName('a');
|
||||
for ( var i=0; i<as.length; i++ )
|
||||
{
|
||||
as.item(i).className="";
|
||||
}
|
||||
var uls = li.getElementsByTagName('ul');
|
||||
for ( var i=0; i<uls.length; i++ )
|
||||
{
|
||||
uls.item(i).style['visibility'] = 'hidden';
|
||||
}
|
||||
}
|
||||
eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
|
||||
}
|
||||
|
||||
// hide the ul elements under the element identified by id
|
||||
function hideUlUnder( id )
|
||||
{
|
||||
document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
|
||||
}
|
||||
|
||||
// show the first ul element found under this element
|
||||
function show()
|
||||
{
|
||||
// show the sub menu
|
||||
this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
|
||||
var currentNode=this;
|
||||
while(currentNode)
|
||||
{
|
||||
if( currentNode.nodeName=='LI')
|
||||
{
|
||||
// currentNode.getElementsByTagName('a')[0].className = 'linkOver';
|
||||
}
|
||||
currentNode=currentNode.parentNode;
|
||||
}
|
||||
// clear the timeout
|
||||
eval ( "clearTimeout( timeout"+ this.id +");" );
|
||||
hideAllOthersUls( this );
|
||||
}
|
||||
|
||||
// hide all ul on the same level of this list item
|
||||
function hideAllOthersUls( currentLi )
|
||||
{
|
||||
var lis = currentLi.parentNode;
|
||||
for ( var i=0; i<lis.childNodes.length; i++ )
|
||||
{
|
||||
if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
|
||||
{
|
||||
hideUlUnderLi( lis.childNodes[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hide all the ul wich are in the li element
|
||||
function hideUlUnderLi( li )
|
||||
{
|
||||
var as = li.getElementsByTagName('a');
|
||||
for ( var i=0; i<as.length; i++ )
|
||||
{
|
||||
as.item(i).className="";
|
||||
}
|
||||
var uls = li.getElementsByTagName('ul');
|
||||
for ( var i=0; i<uls.length; i++ )
|
||||
{
|
||||
uls.item(i).style['visibility'] = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
+4874
-4874
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+698
-698
File diff suppressed because it is too large
Load Diff
+46
-46
@@ -1,50 +1,50 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.client;
|
||||
|
||||
import nl.justobjects.pushlet.core.Event;
|
||||
import nl.justobjects.pushlet.core.Protocol;
|
||||
|
||||
/**
|
||||
* Interface for listener of the PushletClient object.
|
||||
*
|
||||
* @version $Id: PushletClientListener.java,v 1.5 2005/02/21 11:50:37 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
public interface PushletClientListener extends Protocol {
|
||||
/** Abort event from server. */
|
||||
public void onAbort(Event theEvent);
|
||||
|
||||
/** Data event from server. */
|
||||
public void onData(Event theEvent);
|
||||
|
||||
/** Heartbeat event from server. */
|
||||
public void onHeartbeat(Event theEvent);
|
||||
|
||||
/** Error occurred. */
|
||||
public void onError(String message);
|
||||
}
|
||||
|
||||
/*
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.client;
|
||||
|
||||
import nl.justobjects.pushlet.core.Event;
|
||||
import nl.justobjects.pushlet.core.Protocol;
|
||||
|
||||
/**
|
||||
* Interface for listener of the PushletClient object.
|
||||
*
|
||||
* @version $Id: PushletClientListener.java,v 1.5 2005/02/21 11:50:37 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
public interface PushletClientListener extends Protocol {
|
||||
/** Abort event from server. */
|
||||
public void onAbort(Event theEvent);
|
||||
|
||||
/** Data event from server. */
|
||||
public void onData(Event theEvent);
|
||||
|
||||
/** Heartbeat event from server. */
|
||||
public void onHeartbeat(Event theEvent);
|
||||
|
||||
/** Error occurred. */
|
||||
public void onError(String message);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: PushletClientListener.java,v $
|
||||
* Revision 1.5 2005/02/21 11:50:37 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.4 2005/02/15 15:46:31 justb
|
||||
* client API improves
|
||||
*
|
||||
* Revision 1.3 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.2 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.1 2004/03/10 20:14:17 justb
|
||||
* renamed all *JavaPushletClient* to *PushletClient*
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
*
|
||||
*
|
||||
* Revision 1.4 2005/02/15 15:46:31 justb
|
||||
* client API improves
|
||||
*
|
||||
* Revision 1.3 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.2 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.1 2004/03/10 20:14:17 justb
|
||||
* renamed all *JavaPushletClient* to *PushletClient*
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
*
|
||||
*/
|
||||
+203
-203
@@ -1,203 +1,203 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Generic implementation of ClientAdapter for browser clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: BrowserAdapter.java,v 1.6 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
public class BrowserAdapter implements ClientAdapter, Protocol {
|
||||
|
||||
public static final String START_DOCUMENT =
|
||||
"<html><head><meta http-equiv=\"Pragma\" content=\"no-cache\"><meta http-equiv=\"Expires\" content=\"Tue, 31 Dec 1997 23:59:59 GMT\"></head>"
|
||||
+ "<body>"
|
||||
+ "\n<script language=\"JavaScript\"> var url=\" \"; \nfunction refresh() { document.location.href=url; }</script>";
|
||||
public static final String END_DOCUMENT = "</body></html>";
|
||||
|
||||
private PrintWriter servletOut;
|
||||
private HttpServletResponse servletRsp;
|
||||
private int bytesSent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BrowserAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic init.
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
// Keep servlet request/response objects until page ends in stop()
|
||||
// Content type as HTML
|
||||
servletRsp.setStatus(HttpServletResponse.SC_OK);
|
||||
servletRsp.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
// http://www.junlu.com/msg/45902.html
|
||||
// Log.debug("bufsize=" + aRsp.getBufferSize());
|
||||
servletOut = servletRsp.getWriter();
|
||||
send(START_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
Log.debug("BCA event=" + anEvent.toXML());
|
||||
|
||||
// Check if we should refresh
|
||||
if (anEvent.getEventType().equals(Protocol.E_REFRESH)) {
|
||||
// Append refresh and tail of HTML document
|
||||
// Construct the JS callback line to be sent as last line of doc.
|
||||
// This will refresh the request using the unique id to determine
|
||||
// the subscriber instance on the server. The client will wait for
|
||||
// a number of milliseconds.
|
||||
long refreshWaitMillis = Long.parseLong(anEvent.getField(P_WAIT));
|
||||
|
||||
// Create servlet request for requesting next events (refresh)
|
||||
String url = anEvent.getField(P_URL);
|
||||
String jsRefreshTrigger = "\n<script language=\"JavaScript\">url=\'" + url + "\';\n setTimeout(\"refresh()\", " + refreshWaitMillis + ");\n</script>";
|
||||
|
||||
|
||||
send(jsRefreshTrigger + END_DOCUMENT);
|
||||
} else {
|
||||
send(event2JavaScript(anEvent));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End HTML page in client browser.
|
||||
*/
|
||||
public void stop() {
|
||||
// To be garbage collected if adapter remains active
|
||||
servletOut = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send any string to browser.
|
||||
*/
|
||||
protected void send(String s) throws IOException {
|
||||
// Send string to browser.
|
||||
// Log.debug("Adapter: sending: " + s);
|
||||
if (servletOut == null) {
|
||||
throw new IOException("Client adapter was stopped");
|
||||
}
|
||||
|
||||
servletOut.print(s);
|
||||
|
||||
servletOut.flush();
|
||||
|
||||
// Note: this doesn't seem to have effect
|
||||
// in Tomcat 4/5 if the client already disconnected.
|
||||
servletRsp.flushBuffer();
|
||||
|
||||
bytesSent += s.length();
|
||||
Log.debug("bytesSent= " + bytesSent);
|
||||
// Log.debug("BCA sent event: " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Java Event to a JavaScript function call in browser page.
|
||||
*/
|
||||
protected String event2JavaScript(Event event) throws IOException {
|
||||
|
||||
// Convert the event to a comma-separated string.
|
||||
String jsArgs = "";
|
||||
for (Iterator iter = event.getFieldNames(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String value = event.getField(name);
|
||||
String nextArgument = (jsArgs.equals("") ? "" : ",") + "'" + name + "'" + ", \"" + value + "\"";
|
||||
jsArgs += nextArgument;
|
||||
}
|
||||
|
||||
// Construct and return the function call */
|
||||
return "<script language=\"JavaScript\">parent.push(" + jsArgs + ");</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: BrowserAdapter.java,v $
|
||||
* Revision 1.6 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.5 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.4 2006/05/06 00:10:11 justb
|
||||
* various chgs but not too serious...
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:44 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.12 2005/02/15 13:30:23 justb
|
||||
* changes for Tomcat buffering (now working in tc4 and 5.0)
|
||||
*
|
||||
* Revision 1.11 2005/01/24 22:45:58 justb
|
||||
* getting safari to work
|
||||
*
|
||||
* Revision 1.10 2005/01/18 16:46:27 justb
|
||||
* buffer size setting ignored by tomcat workings
|
||||
*
|
||||
* Revision 1.9 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.5 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:07 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:02 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Generic implementation of ClientAdapter for browser clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: BrowserAdapter.java,v 1.6 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
public class BrowserAdapter implements ClientAdapter, Protocol {
|
||||
|
||||
public static final String START_DOCUMENT =
|
||||
"<html><head><meta http-equiv=\"Pragma\" content=\"no-cache\"><meta http-equiv=\"Expires\" content=\"Tue, 31 Dec 1997 23:59:59 GMT\"></head>"
|
||||
+ "<body>"
|
||||
+ "\n<script language=\"JavaScript\"> var url=\" \"; \nfunction refresh() { document.location.href=url; }</script>";
|
||||
public static final String END_DOCUMENT = "</body></html>";
|
||||
|
||||
private PrintWriter servletOut;
|
||||
private HttpServletResponse servletRsp;
|
||||
private int bytesSent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BrowserAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic init.
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
// Keep servlet request/response objects until page ends in stop()
|
||||
// Content type as HTML
|
||||
servletRsp.setStatus(HttpServletResponse.SC_OK);
|
||||
servletRsp.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
// http://www.junlu.com/msg/45902.html
|
||||
// Log.debug("bufsize=" + aRsp.getBufferSize());
|
||||
servletOut = servletRsp.getWriter();
|
||||
send(START_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
Log.debug("BCA event=" + anEvent.toXML());
|
||||
|
||||
// Check if we should refresh
|
||||
if (anEvent.getEventType().equals(Protocol.E_REFRESH)) {
|
||||
// Append refresh and tail of HTML document
|
||||
// Construct the JS callback line to be sent as last line of doc.
|
||||
// This will refresh the request using the unique id to determine
|
||||
// the subscriber instance on the server. The client will wait for
|
||||
// a number of milliseconds.
|
||||
long refreshWaitMillis = Long.parseLong(anEvent.getField(P_WAIT));
|
||||
|
||||
// Create servlet request for requesting next events (refresh)
|
||||
String url = anEvent.getField(P_URL);
|
||||
String jsRefreshTrigger = "\n<script language=\"JavaScript\">url=\'" + url + "\';\n setTimeout(\"refresh()\", " + refreshWaitMillis + ");\n</script>";
|
||||
|
||||
|
||||
send(jsRefreshTrigger + END_DOCUMENT);
|
||||
} else {
|
||||
send(event2JavaScript(anEvent));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End HTML page in client browser.
|
||||
*/
|
||||
public void stop() {
|
||||
// To be garbage collected if adapter remains active
|
||||
servletOut = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send any string to browser.
|
||||
*/
|
||||
protected void send(String s) throws IOException {
|
||||
// Send string to browser.
|
||||
// Log.debug("Adapter: sending: " + s);
|
||||
if (servletOut == null) {
|
||||
throw new IOException("Client adapter was stopped");
|
||||
}
|
||||
|
||||
servletOut.print(s);
|
||||
|
||||
servletOut.flush();
|
||||
|
||||
// Note: this doesn't seem to have effect
|
||||
// in Tomcat 4/5 if the client already disconnected.
|
||||
servletRsp.flushBuffer();
|
||||
|
||||
bytesSent += s.length();
|
||||
Log.debug("bytesSent= " + bytesSent);
|
||||
// Log.debug("BCA sent event: " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Java Event to a JavaScript function call in browser page.
|
||||
*/
|
||||
protected String event2JavaScript(Event event) throws IOException {
|
||||
|
||||
// Convert the event to a comma-separated string.
|
||||
String jsArgs = "";
|
||||
for (Iterator iter = event.getFieldNames(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String value = event.getField(name);
|
||||
String nextArgument = (jsArgs.equals("") ? "" : ",") + "'" + name + "'" + ", \"" + value + "\"";
|
||||
jsArgs += nextArgument;
|
||||
}
|
||||
|
||||
// Construct and return the function call */
|
||||
return "<script language=\"JavaScript\">parent.push(" + jsArgs + ");</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: BrowserAdapter.java,v $
|
||||
* Revision 1.6 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.5 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.4 2006/05/06 00:10:11 justb
|
||||
* various chgs but not too serious...
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:44 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.12 2005/02/15 13:30:23 justb
|
||||
* changes for Tomcat buffering (now working in tc4 and 5.0)
|
||||
*
|
||||
* Revision 1.11 2005/01/24 22:45:58 justb
|
||||
* getting safari to work
|
||||
*
|
||||
* Revision 1.10 2005/01/18 16:46:27 justb
|
||||
* buffer size setting ignored by tomcat workings
|
||||
*
|
||||
* Revision 1.9 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.5 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:07 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:02 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+72
-72
@@ -1,72 +1,72 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Adapter interface for encapsulation of specific HTTP clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: ClientAdapter.java,v 1.8 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public interface ClientAdapter {
|
||||
|
||||
/**
|
||||
* Start event push.
|
||||
*/
|
||||
public void start() throws IOException;
|
||||
|
||||
/**
|
||||
* Push single Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException;
|
||||
|
||||
/**
|
||||
* Stop event push.
|
||||
*/
|
||||
public void stop() throws IOException;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: ClientAdapter.java,v $
|
||||
* Revision 1.8 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.7 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:45 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Adapter interface for encapsulation of specific HTTP clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: ClientAdapter.java,v 1.8 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public interface ClientAdapter {
|
||||
|
||||
/**
|
||||
* Start event push.
|
||||
*/
|
||||
public void start() throws IOException;
|
||||
|
||||
/**
|
||||
* Push single Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException;
|
||||
|
||||
/**
|
||||
* Stop event push.
|
||||
*/
|
||||
public void stop() throws IOException;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: ClientAdapter.java,v $
|
||||
* Revision 1.8 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.7 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:45 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+265
-265
File diff suppressed because it is too large
Load Diff
+184
-184
@@ -1,184 +1,184 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the event data.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: Event.java,v 1.13 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public class Event implements Protocol, Serializable {
|
||||
|
||||
protected Map attributes = new HashMap(3);
|
||||
|
||||
public Event(String anEventType) {
|
||||
this(anEventType, null);
|
||||
}
|
||||
|
||||
public Event(String anEventType, Map theAttributes) {
|
||||
|
||||
if (theAttributes != null) {
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
// Set required field event type
|
||||
setField(P_EVENT, anEventType);
|
||||
|
||||
// Set time in seconds since 1970
|
||||
setField(P_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public Event(Map theAttributes) {
|
||||
if (!theAttributes.containsKey(P_EVENT)) {
|
||||
throw new IllegalArgumentException(P_EVENT + " not found in attributes");
|
||||
}
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject) {
|
||||
return createDataEvent(aSubject, null);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject, Map theAttributes) {
|
||||
Event dataEvent = new Event(E_DATA, theAttributes);
|
||||
dataEvent.setField(P_SUBJECT, aSubject);
|
||||
return dataEvent;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return getField(P_EVENT);
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return getField(P_SUBJECT);
|
||||
}
|
||||
|
||||
public void setField(String name, String value) {
|
||||
attributes.put(name, value);
|
||||
}
|
||||
|
||||
public void setField(String name, int value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public void setField(String name, long value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public String getField(String name) {
|
||||
return (String) attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return field; if null return default.
|
||||
*/
|
||||
public String getField(String name, String aDefault) {
|
||||
String result = getField(name);
|
||||
return result == null ? aDefault : result;
|
||||
}
|
||||
|
||||
public Iterator getFieldNames() {
|
||||
return attributes.keySet().iterator();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return attributes.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to HTTP query string.
|
||||
*/
|
||||
public String toQueryString() {
|
||||
String queryString = "";
|
||||
String amp = "";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
queryString = queryString + amp + nextAttrName + "=" + nextAttrValue;
|
||||
// After first add "&".
|
||||
amp = "&";
|
||||
}
|
||||
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public String toXML(boolean strict) {
|
||||
String xmlString = "<event ";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
xmlString = xmlString + nextAttrName + "=\"" + (strict ? Sys.forHTMLTag(nextAttrValue) : nextAttrValue) + "\" ";
|
||||
}
|
||||
|
||||
xmlString += "/>";
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
return toXML(false);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
// Clone the Event by using copy constructor
|
||||
return new Event(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy given attributes into event attributes
|
||||
*/
|
||||
private void setAttrs(Map theAttributes) {
|
||||
attributes.putAll(theAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Event.java,v $
|
||||
* Revision 1.13 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.12 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.11 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.10 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.9 2005/02/20 13:05:32 justb
|
||||
* removed the Postlet (integrated in Pushlet protocol)
|
||||
*
|
||||
* Revision 1.8 2005/02/15 13:29:24 justb
|
||||
* add toQueryString()
|
||||
*
|
||||
* Revision 1.7 2005/01/18 16:47:10 justb
|
||||
* protocol changes for v2 and publishing from pushlet client
|
||||
*
|
||||
* Revision 1.6 2005/01/13 14:47:15 justb
|
||||
* control evt: send response on same (control) connection
|
||||
*
|
||||
* Revision 1.5 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.4 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the event data.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: Event.java,v 1.13 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public class Event implements Protocol, Serializable {
|
||||
|
||||
protected Map attributes = new HashMap(3);
|
||||
|
||||
public Event(String anEventType) {
|
||||
this(anEventType, null);
|
||||
}
|
||||
|
||||
public Event(String anEventType, Map theAttributes) {
|
||||
|
||||
if (theAttributes != null) {
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
// Set required field event type
|
||||
setField(P_EVENT, anEventType);
|
||||
|
||||
// Set time in seconds since 1970
|
||||
setField(P_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public Event(Map theAttributes) {
|
||||
if (!theAttributes.containsKey(P_EVENT)) {
|
||||
throw new IllegalArgumentException(P_EVENT + " not found in attributes");
|
||||
}
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject) {
|
||||
return createDataEvent(aSubject, null);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject, Map theAttributes) {
|
||||
Event dataEvent = new Event(E_DATA, theAttributes);
|
||||
dataEvent.setField(P_SUBJECT, aSubject);
|
||||
return dataEvent;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return getField(P_EVENT);
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return getField(P_SUBJECT);
|
||||
}
|
||||
|
||||
public void setField(String name, String value) {
|
||||
attributes.put(name, value);
|
||||
}
|
||||
|
||||
public void setField(String name, int value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public void setField(String name, long value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public String getField(String name) {
|
||||
return (String) attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return field; if null return default.
|
||||
*/
|
||||
public String getField(String name, String aDefault) {
|
||||
String result = getField(name);
|
||||
return result == null ? aDefault : result;
|
||||
}
|
||||
|
||||
public Iterator getFieldNames() {
|
||||
return attributes.keySet().iterator();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return attributes.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to HTTP query string.
|
||||
*/
|
||||
public String toQueryString() {
|
||||
String queryString = "";
|
||||
String amp = "";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
queryString = queryString + amp + nextAttrName + "=" + nextAttrValue;
|
||||
// After first add "&".
|
||||
amp = "&";
|
||||
}
|
||||
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public String toXML(boolean strict) {
|
||||
String xmlString = "<event ";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
xmlString = xmlString + nextAttrName + "=\"" + (strict ? Sys.forHTMLTag(nextAttrValue) : nextAttrValue) + "\" ";
|
||||
}
|
||||
|
||||
xmlString += "/>";
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
return toXML(false);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
// Clone the Event by using copy constructor
|
||||
return new Event(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy given attributes into event attributes
|
||||
*/
|
||||
private void setAttrs(Map theAttributes) {
|
||||
attributes.putAll(theAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Event.java,v $
|
||||
* Revision 1.13 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.12 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.11 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.10 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.9 2005/02/20 13:05:32 justb
|
||||
* removed the Postlet (integrated in Pushlet protocol)
|
||||
*
|
||||
* Revision 1.8 2005/02/15 13:29:24 justb
|
||||
* add toQueryString()
|
||||
*
|
||||
* Revision 1.7 2005/01/18 16:47:10 justb
|
||||
* protocol changes for v2 and publishing from pushlet client
|
||||
*
|
||||
* Revision 1.6 2005/01/13 14:47:15 justb
|
||||
* control evt: send response on same (control) connection
|
||||
*
|
||||
* Revision 1.5 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.4 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
*/
|
||||
|
||||
+185
-185
@@ -1,185 +1,185 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventPullSource.java,v 1.15 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* ABC for specifc EventPullSources.
|
||||
*/
|
||||
abstract public class EventPullSource implements EventSource, Runnable {
|
||||
private volatile boolean alive = false;
|
||||
private volatile boolean active = false;
|
||||
private static int threadNum = 0;
|
||||
private Thread thread;
|
||||
|
||||
public EventPullSource() {
|
||||
}
|
||||
|
||||
abstract protected long getSleepTime();
|
||||
|
||||
abstract protected Event pullEvent();
|
||||
|
||||
public void start() {
|
||||
thread = new Thread(this, "EventPullSource-" + (++threadNum));
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the event generator thread.
|
||||
*/
|
||||
public void stop() {
|
||||
alive = false;
|
||||
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the event generator thread.
|
||||
*/
|
||||
synchronized public void activate() {
|
||||
if (active) {
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
if (!alive) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
Log.debug(getClass().getName() + ": notifying...");
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the event generator thread.
|
||||
*/
|
||||
public void passivate() {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main loop: sleep, generate event and publish.
|
||||
*/
|
||||
public void run() {
|
||||
Log.debug(getClass().getName() + ": starting...");
|
||||
alive = true;
|
||||
while (alive) {
|
||||
try {
|
||||
|
||||
Thread.sleep(getSleepTime());
|
||||
|
||||
// Stopped during sleep: end loop.
|
||||
if (!alive) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If passivated wait until we get
|
||||
// get notify()-ied. If there are no subscribers
|
||||
// it wasts CPU to remain producing events...
|
||||
synchronized (this) {
|
||||
while (!active) {
|
||||
Log.debug(getClass().getName() + ": waiting...");
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
// Derived class should produce an event.
|
||||
Event event = pullEvent();
|
||||
|
||||
// Let the publisher push it to subscribers.
|
||||
Dispatcher.getInstance().multicast(event);
|
||||
} catch (Throwable t) {
|
||||
Log.warn("EventPullSource exception while multicasting ", t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.debug(getClass().getName() + ": stopped");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventPullSource.java,v $
|
||||
* Revision 1.15 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.14 2005/02/28 09:14:55 justb
|
||||
* sessmgr/dispatcher factory/singleton support
|
||||
*
|
||||
* Revision 1.13 2005/02/21 16:59:08 justb
|
||||
* SessionManager and session lease introduced
|
||||
*
|
||||
* Revision 1.12 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/18 09:54:15 justb
|
||||
* refactor: rename Publisher Dispatcher and single Subscriber class
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventPullSource.java,v 1.15 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* ABC for specifc EventPullSources.
|
||||
*/
|
||||
abstract public class EventPullSource implements EventSource, Runnable {
|
||||
private volatile boolean alive = false;
|
||||
private volatile boolean active = false;
|
||||
private static int threadNum = 0;
|
||||
private Thread thread;
|
||||
|
||||
public EventPullSource() {
|
||||
}
|
||||
|
||||
abstract protected long getSleepTime();
|
||||
|
||||
abstract protected Event pullEvent();
|
||||
|
||||
public void start() {
|
||||
thread = new Thread(this, "EventPullSource-" + (++threadNum));
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the event generator thread.
|
||||
*/
|
||||
public void stop() {
|
||||
alive = false;
|
||||
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the event generator thread.
|
||||
*/
|
||||
synchronized public void activate() {
|
||||
if (active) {
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
if (!alive) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
Log.debug(getClass().getName() + ": notifying...");
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the event generator thread.
|
||||
*/
|
||||
public void passivate() {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main loop: sleep, generate event and publish.
|
||||
*/
|
||||
public void run() {
|
||||
Log.debug(getClass().getName() + ": starting...");
|
||||
alive = true;
|
||||
while (alive) {
|
||||
try {
|
||||
|
||||
Thread.sleep(getSleepTime());
|
||||
|
||||
// Stopped during sleep: end loop.
|
||||
if (!alive) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If passivated wait until we get
|
||||
// get notify()-ied. If there are no subscribers
|
||||
// it wasts CPU to remain producing events...
|
||||
synchronized (this) {
|
||||
while (!active) {
|
||||
Log.debug(getClass().getName() + ": waiting...");
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
// Derived class should produce an event.
|
||||
Event event = pullEvent();
|
||||
|
||||
// Let the publisher push it to subscribers.
|
||||
Dispatcher.getInstance().multicast(event);
|
||||
} catch (Throwable t) {
|
||||
Log.warn("EventPullSource exception while multicasting ", t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.debug(getClass().getName() + ": stopped");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventPullSource.java,v $
|
||||
* Revision 1.15 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.14 2005/02/28 09:14:55 justb
|
||||
* sessmgr/dispatcher factory/singleton support
|
||||
*
|
||||
* Revision 1.13 2005/02/21 16:59:08 justb
|
||||
* SessionManager and session lease introduced
|
||||
*
|
||||
* Revision 1.12 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/18 09:54:15 justb
|
||||
* refactor: rename Publisher Dispatcher and single Subscriber class
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+269
-269
File diff suppressed because it is too large
Load Diff
+79
-79
@@ -1,79 +1,79 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventSource.java,v 1.7 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface for specifc Event(Pull/Push)Sources.
|
||||
*/
|
||||
public interface EventSource {
|
||||
/**
|
||||
* Activate the event source.
|
||||
*/
|
||||
public void activate();
|
||||
|
||||
/**
|
||||
* Deactivate the event source.
|
||||
*/
|
||||
public void passivate();
|
||||
|
||||
/**
|
||||
* Halt the event source.
|
||||
*/
|
||||
public void stop();
|
||||
|
||||
/**
|
||||
* @author thomas genin
|
||||
* gives access to the servlet context of pushlet to the source class
|
||||
*/
|
||||
public void setServletContext(ServletContext srvCtxt);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSource.java,v $
|
||||
* Revision 1.7 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventSource.java,v 1.7 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface for specifc Event(Pull/Push)Sources.
|
||||
*/
|
||||
public interface EventSource {
|
||||
/**
|
||||
* Activate the event source.
|
||||
*/
|
||||
public void activate();
|
||||
|
||||
/**
|
||||
* Deactivate the event source.
|
||||
*/
|
||||
public void passivate();
|
||||
|
||||
/**
|
||||
* Halt the event source.
|
||||
*/
|
||||
public void stop();
|
||||
|
||||
/**
|
||||
* @author thomas genin
|
||||
* gives access to the servlet context of pushlet to the source class
|
||||
*/
|
||||
public void setServletContext(ServletContext srvCtxt);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSource.java,v $
|
||||
* Revision 1.7 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+175
-175
@@ -1,175 +1,175 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* Maintains lifecycle of event sources.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: EventSourceManager.java,v 1.14 2007/11/10 13:44:02 justb Exp $
|
||||
*/
|
||||
public class EventSourceManager {
|
||||
private static Vector eventSources = new Vector(0);
|
||||
private static final String PROPERTIES_FILE = "sources.properties";
|
||||
|
||||
/**
|
||||
* Initialize event sources from properties file.
|
||||
*/
|
||||
public static void start(String aDirPath,ServletContext srvCtxt) {
|
||||
// Load Event sources using properties file.
|
||||
Log.info("EventSourceManager: start");
|
||||
|
||||
Properties properties = null;
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesResource(PROPERTIES_FILE);
|
||||
} catch (Throwable t) {
|
||||
// Try from provided dir (e.g. WEB_INF/pushlet.properties)
|
||||
String filePath = aDirPath + File.separator + PROPERTIES_FILE;
|
||||
Log.info("EventSourceManager: cannot load " + PROPERTIES_FILE + " from classpath, will try from " + filePath);
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesFile(filePath);
|
||||
} catch (Throwable t2) {
|
||||
Log.fatal("EventSourceManager: cannot load properties file from " + filePath, t);
|
||||
|
||||
// Give up
|
||||
Log.warn("EventSourceManager: not starting local event sources (maybe that is what you want)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create event source collection
|
||||
eventSources = new Vector(properties.size());
|
||||
|
||||
// Add the configured sources
|
||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
||||
String nextKey = (String) e.nextElement();
|
||||
String nextClass = properties.getProperty(nextKey);
|
||||
EventSource nextEventSource = null;
|
||||
try {
|
||||
nextEventSource = (EventSource) Class.forName(nextClass).newInstance();
|
||||
//rajout thomas genin
|
||||
nextEventSource.setServletContext(srvCtxt);
|
||||
//////////////////////
|
||||
Log.info("created EventSource: key=" + nextKey + " class=" + nextClass);
|
||||
eventSources.addElement(nextEventSource);
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.warn("Cannot create EventSource: class=" + nextClass, ex);
|
||||
}
|
||||
}
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all event sources.
|
||||
*/
|
||||
public static void activate() {
|
||||
Log.info("Activating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).activate();
|
||||
}
|
||||
Log.info("EventSources activated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all event sources.
|
||||
*/
|
||||
public static void passivate() {
|
||||
Log.info("Passivating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).passivate();
|
||||
}
|
||||
Log.info("EventSources passivated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Halt event sources.
|
||||
*/
|
||||
public static void stop() {
|
||||
Log.info("Stopping " + eventSources.size() + " EventSources...");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).stop();
|
||||
}
|
||||
Log.info("EventSources stopped");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSourceManager.java,v $
|
||||
* Revision 1.14 2007/11/10 13:44:02 justb
|
||||
* pushlet.properties and sources.properties can now also be put under WEB-INF
|
||||
*
|
||||
* Revision 1.13 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.12 2005/02/18 12:36:47 justb
|
||||
* changes for renaming and configurability
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/15 13:29:49 justb
|
||||
* use Sys.loadPropertiesResource()
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/08/12 13:18:54 justb
|
||||
* cosmetic changes
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:41:35 justb
|
||||
* replace static initalizer with explicit init()
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/31 08:26:54 just
|
||||
* Changed classloader that loads eventsources.properties to use EventSourceManager's classloader
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* Maintains lifecycle of event sources.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: EventSourceManager.java,v 1.14 2007/11/10 13:44:02 justb Exp $
|
||||
*/
|
||||
public class EventSourceManager {
|
||||
private static Vector eventSources = new Vector(0);
|
||||
private static final String PROPERTIES_FILE = "sources.properties";
|
||||
|
||||
/**
|
||||
* Initialize event sources from properties file.
|
||||
*/
|
||||
public static void start(String aDirPath,ServletContext srvCtxt) {
|
||||
// Load Event sources using properties file.
|
||||
Log.info("EventSourceManager: start");
|
||||
|
||||
Properties properties = null;
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesResource(PROPERTIES_FILE);
|
||||
} catch (Throwable t) {
|
||||
// Try from provided dir (e.g. WEB_INF/pushlet.properties)
|
||||
String filePath = aDirPath + File.separator + PROPERTIES_FILE;
|
||||
Log.info("EventSourceManager: cannot load " + PROPERTIES_FILE + " from classpath, will try from " + filePath);
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesFile(filePath);
|
||||
} catch (Throwable t2) {
|
||||
Log.fatal("EventSourceManager: cannot load properties file from " + filePath, t);
|
||||
|
||||
// Give up
|
||||
Log.warn("EventSourceManager: not starting local event sources (maybe that is what you want)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create event source collection
|
||||
eventSources = new Vector(properties.size());
|
||||
|
||||
// Add the configured sources
|
||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
||||
String nextKey = (String) e.nextElement();
|
||||
String nextClass = properties.getProperty(nextKey);
|
||||
EventSource nextEventSource = null;
|
||||
try {
|
||||
nextEventSource = (EventSource) Class.forName(nextClass).newInstance();
|
||||
//rajout thomas genin
|
||||
nextEventSource.setServletContext(srvCtxt);
|
||||
//////////////////////
|
||||
Log.info("created EventSource: key=" + nextKey + " class=" + nextClass);
|
||||
eventSources.addElement(nextEventSource);
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.warn("Cannot create EventSource: class=" + nextClass, ex);
|
||||
}
|
||||
}
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all event sources.
|
||||
*/
|
||||
public static void activate() {
|
||||
Log.info("Activating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).activate();
|
||||
}
|
||||
Log.info("EventSources activated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all event sources.
|
||||
*/
|
||||
public static void passivate() {
|
||||
Log.info("Passivating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).passivate();
|
||||
}
|
||||
Log.info("EventSources passivated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Halt event sources.
|
||||
*/
|
||||
public static void stop() {
|
||||
Log.info("Stopping " + eventSources.size() + " EventSources...");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).stop();
|
||||
}
|
||||
Log.info("EventSources stopped");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSourceManager.java,v $
|
||||
* Revision 1.14 2007/11/10 13:44:02 justb
|
||||
* pushlet.properties and sources.properties can now also be put under WEB-INF
|
||||
*
|
||||
* Revision 1.13 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.12 2005/02/18 12:36:47 justb
|
||||
* changes for renaming and configurability
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/15 13:29:49 justb
|
||||
* use Sys.loadPropertiesResource()
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/08/12 13:18:54 justb
|
||||
* cosmetic changes
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:41:35 justb
|
||||
* replace static initalizer with explicit init()
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/31 08:26:54 just
|
||||
* Changed classloader that loads eventsources.properties to use EventSourceManager's classloader
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+99
-99
@@ -1,99 +1,99 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* Implementation of ClientAdapter that sends Events as serialized objects.
|
||||
* <p/>
|
||||
* NOTE: You are discouraged to use this adapter, since it is Java-only
|
||||
* and may have JVM-specific problems. Far better choice is to use XML
|
||||
* and the XMLAdapter.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: SerializedAdapter.java,v 1.4 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
class SerializedAdapter implements ClientAdapter {
|
||||
private ObjectOutputStream out = null;
|
||||
public static final String CONTENT_TYPE = "application/x-java-serialized-object";
|
||||
private HttpServletResponse servletRsp;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public SerializedAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
servletRsp.setContentType(CONTENT_TYPE);
|
||||
|
||||
// Use a serialized object output stream
|
||||
out = new ObjectOutputStream(servletRsp.getOutputStream());
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
out.writeObject(anEvent);
|
||||
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
public void stop() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: SerializedAdapter.java,v $
|
||||
* Revision 1.4 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:13:48 justb
|
||||
* fixed blocking for java.net.URL with HTTP/1.1 (JVMs > 1.1)
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:18 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* Implementation of ClientAdapter that sends Events as serialized objects.
|
||||
* <p/>
|
||||
* NOTE: You are discouraged to use this adapter, since it is Java-only
|
||||
* and may have JVM-specific problems. Far better choice is to use XML
|
||||
* and the XMLAdapter.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: SerializedAdapter.java,v 1.4 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
class SerializedAdapter implements ClientAdapter {
|
||||
private ObjectOutputStream out = null;
|
||||
public static final String CONTENT_TYPE = "application/x-java-serialized-object";
|
||||
private HttpServletResponse servletRsp;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public SerializedAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
servletRsp.setContentType(CONTENT_TYPE);
|
||||
|
||||
// Use a serialized object output stream
|
||||
out = new ObjectOutputStream(servletRsp.getOutputStream());
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
out.writeObject(anEvent);
|
||||
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
public void stop() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: SerializedAdapter.java,v $
|
||||
* Revision 1.4 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:13:48 justb
|
||||
* fixed blocking for java.net.URL with HTTP/1.1 (JVMs > 1.1)
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:18 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+469
-469
File diff suppressed because it is too large
Load Diff
+137
-137
@@ -1,137 +1,137 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* ClientAdapter that sends Events as XML.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: XMLAdapter.java,v 1.7 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
class XMLAdapter implements ClientAdapter {
|
||||
/**
|
||||
* Header for strict XML
|
||||
*/
|
||||
// public static final String XML_HEAD = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
|
||||
private String contentType = "text/plain;charset=UTF-8";
|
||||
private ServletOutputStream out = null;
|
||||
private HttpServletResponse servletRsp;
|
||||
private boolean strictXML;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse) {
|
||||
this(aServletResponse, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse, boolean useStrictXML) {
|
||||
servletRsp = aServletResponse;
|
||||
|
||||
// Strict XML implies returning a complete XML document
|
||||
strictXML = useStrictXML;
|
||||
if (strictXML) {
|
||||
contentType = "text/xml;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
// If content type is plain text
|
||||
// then this is not a complete XML document, but rather
|
||||
// a stream of XML documents where each document is
|
||||
// an Event. In strict XML mode a complete document is returned.
|
||||
servletRsp.setContentType(contentType);
|
||||
|
||||
out = servletRsp.getOutputStream();
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
|
||||
// Start XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("<pushlet>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force client to refresh the request.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
debug("event=" + anEvent);
|
||||
|
||||
// Send the event as XML to the client and flush.
|
||||
out.print(anEvent.toXML(strictXML));
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
public void stop() throws IOException {
|
||||
// Close XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("</pushlet>");
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void debug(String s) {
|
||||
Log.debug("[XMLAdapter]" + s);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: XMLAdapter.java,v $
|
||||
* Revision 1.7 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.6 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.5 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.4 2005/05/06 19:44:00 justb
|
||||
* added xml-strict format
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:47 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.5 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.4 2003/08/13 14:00:00 justb
|
||||
* some testing for applets; no real change
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:06 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/19 21:56:29 justb
|
||||
* various fixes for applet clients
|
||||
*
|
||||
* Revision 1.1 2003/05/18 16:12:28 justb
|
||||
* adding support for XML encoded Events
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* ClientAdapter that sends Events as XML.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: XMLAdapter.java,v 1.7 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
class XMLAdapter implements ClientAdapter {
|
||||
/**
|
||||
* Header for strict XML
|
||||
*/
|
||||
// public static final String XML_HEAD = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
|
||||
private String contentType = "text/plain;charset=UTF-8";
|
||||
private ServletOutputStream out = null;
|
||||
private HttpServletResponse servletRsp;
|
||||
private boolean strictXML;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse) {
|
||||
this(aServletResponse, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse, boolean useStrictXML) {
|
||||
servletRsp = aServletResponse;
|
||||
|
||||
// Strict XML implies returning a complete XML document
|
||||
strictXML = useStrictXML;
|
||||
if (strictXML) {
|
||||
contentType = "text/xml;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
// If content type is plain text
|
||||
// then this is not a complete XML document, but rather
|
||||
// a stream of XML documents where each document is
|
||||
// an Event. In strict XML mode a complete document is returned.
|
||||
servletRsp.setContentType(contentType);
|
||||
|
||||
out = servletRsp.getOutputStream();
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
|
||||
// Start XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("<pushlet>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force client to refresh the request.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
debug("event=" + anEvent);
|
||||
|
||||
// Send the event as XML to the client and flush.
|
||||
out.print(anEvent.toXML(strictXML));
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
public void stop() throws IOException {
|
||||
// Close XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("</pushlet>");
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void debug(String s) {
|
||||
Log.debug("[XMLAdapter]" + s);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: XMLAdapter.java,v $
|
||||
* Revision 1.7 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.6 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.5 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.4 2005/05/06 19:44:00 justb
|
||||
* added xml-strict format
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:47 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.5 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.4 2003/08/13 14:00:00 justb
|
||||
* some testing for applets; no real change
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:06 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/19 21:56:29 justb
|
||||
* various fixes for applet clients
|
||||
*
|
||||
* Revision 1.1 2003/05/18 16:12:28 justb
|
||||
* adding support for XML encoded Events
|
||||
*/
|
||||
|
||||
+294
-294
File diff suppressed because it is too large
Load Diff
+163
-163
@@ -1,164 +1,164 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
/**
|
||||
* Default logger.
|
||||
* <p/>
|
||||
* Logs to stdout. Override this class by setting "logger.class" in pushlet.properties to your own logger
|
||||
* to integrate your own logging library.
|
||||
*
|
||||
* @author Just van den Broecke
|
||||
* @version $Id: DefaultLogger.java,v 1.2 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class DefaultLogger implements PushletLogger {
|
||||
|
||||
|
||||
/**
|
||||
* Level intialized with default.
|
||||
*/
|
||||
private int level = LOG_LEVEL_INFO;
|
||||
|
||||
public DefaultLogger() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void trace(String aMessage) {
|
||||
if (level < LOG_LEVEL_TRACE) {
|
||||
return;
|
||||
}
|
||||
print("TRACE", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void debug(String aMessage) {
|
||||
if (level < LOG_LEVEL_DEBUG) {
|
||||
return;
|
||||
}
|
||||
print("DEBUG", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void info(String aMessage) {
|
||||
if (level < LOG_LEVEL_INFO) {
|
||||
return;
|
||||
}
|
||||
print("INFO", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void warn(String aMessage) {
|
||||
if (level < LOG_LEVEL_WARN) {
|
||||
return;
|
||||
}
|
||||
print("WARN", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable) {
|
||||
warn(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void error(String aMessage) {
|
||||
if (level < LOG_LEVEL_ERROR) {
|
||||
return;
|
||||
}
|
||||
print("FATAL", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable) {
|
||||
error(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void fatal(String aMessage) {
|
||||
if (level < LOG_LEVEL_FATAL) {
|
||||
return;
|
||||
}
|
||||
print("FATAL", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable) {
|
||||
fatal(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel the message to be logged
|
||||
*/
|
||||
public void setLevel(int aLevel) {
|
||||
level = aLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print message.
|
||||
*
|
||||
* @param aTag the log type
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
private void print(String aTag, String aMessage) {
|
||||
// SImple std out e.g. to catalina.out in Tomcat
|
||||
System.out.println("Pushlet[" + aTag + "] " + aMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: DefaultLogger.java,v $
|
||||
* Revision 1.2 2007/12/07 12:57:40 justb
|
||||
* added log4j and make it the default logging method
|
||||
*
|
||||
* Revision 1.1 2007/11/23 21:10:17 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
*
|
||||
*
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
/**
|
||||
* Default logger.
|
||||
* <p/>
|
||||
* Logs to stdout. Override this class by setting "logger.class" in pushlet.properties to your own logger
|
||||
* to integrate your own logging library.
|
||||
*
|
||||
* @author Just van den Broecke
|
||||
* @version $Id: DefaultLogger.java,v 1.2 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class DefaultLogger implements PushletLogger {
|
||||
|
||||
|
||||
/**
|
||||
* Level intialized with default.
|
||||
*/
|
||||
private int level = LOG_LEVEL_INFO;
|
||||
|
||||
public DefaultLogger() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void trace(String aMessage) {
|
||||
if (level < LOG_LEVEL_TRACE) {
|
||||
return;
|
||||
}
|
||||
print("TRACE", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void debug(String aMessage) {
|
||||
if (level < LOG_LEVEL_DEBUG) {
|
||||
return;
|
||||
}
|
||||
print("DEBUG", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void info(String aMessage) {
|
||||
if (level < LOG_LEVEL_INFO) {
|
||||
return;
|
||||
}
|
||||
print("INFO", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void warn(String aMessage) {
|
||||
if (level < LOG_LEVEL_WARN) {
|
||||
return;
|
||||
}
|
||||
print("WARN", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable) {
|
||||
warn(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void error(String aMessage) {
|
||||
if (level < LOG_LEVEL_ERROR) {
|
||||
return;
|
||||
}
|
||||
print("FATAL", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable) {
|
||||
error(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void fatal(String aMessage) {
|
||||
if (level < LOG_LEVEL_FATAL) {
|
||||
return;
|
||||
}
|
||||
print("FATAL", aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable) {
|
||||
fatal(aMessage + " exception=" + aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel the message to be logged
|
||||
*/
|
||||
public void setLevel(int aLevel) {
|
||||
level = aLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print message.
|
||||
*
|
||||
* @param aTag the log type
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
private void print(String aTag, String aMessage) {
|
||||
// SImple std out e.g. to catalina.out in Tomcat
|
||||
System.out.println("Pushlet[" + aTag + "] " + aMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: DefaultLogger.java,v $
|
||||
* Revision 1.2 2007/12/07 12:57:40 justb
|
||||
* added log4j and make it the default logging method
|
||||
*
|
||||
* Revision 1.1 2007/11/23 21:10:17 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
+177
-177
@@ -1,178 +1,178 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import nl.justobjects.pushlet.core.Config;
|
||||
import nl.justobjects.pushlet.core.ConfigDefs;
|
||||
|
||||
/**
|
||||
* Logging wrapper.
|
||||
* <p/>
|
||||
* Provides a hook to direct logging to your own logging library. Override the DefaultLogger class by setting
|
||||
* "logger.class" in pushlet.properties to your own logger
|
||||
* to integrate your own logging library.
|
||||
*
|
||||
* @author Just van den Broecke
|
||||
* @version $Id: Log.java,v 1.5 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class Log implements ConfigDefs {
|
||||
/**
|
||||
* Init with default to have at least some logging.
|
||||
*/
|
||||
private static PushletLogger logger = new DefaultLogger();
|
||||
|
||||
/**
|
||||
* General purpose initialization.
|
||||
*/
|
||||
static public void init() {
|
||||
try {
|
||||
logger = (PushletLogger) Config.getClass(LOGGER_CLASS, "nl.justobjects.pushlet.util.DefaultLogger").newInstance();
|
||||
} catch (Throwable t) {
|
||||
// Hmmm cannot log this since we don't have a log...
|
||||
System.out.println("Cannot instantiate Logger from config ex=" + t);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.init();
|
||||
|
||||
// Set log level
|
||||
logger.setLevel(Config.getIntProperty(Config.LOG_LEVEL));
|
||||
|
||||
logger.info("Logging intialized logger class=" + logger.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void trace(String aMessage) {
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void debug(String aMessage) {
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void info(String aMessage) {
|
||||
logger.info(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void warn(String aMessage) {
|
||||
logger.warn(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void warn(String aMessage, Throwable aThrowable) {
|
||||
logger.warn(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void error(String aMessage) {
|
||||
logger.error(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void error(String aMessage, Throwable aThrowable) {
|
||||
logger.error(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void fatal(String aMessage) {
|
||||
logger.fatal(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void fatal(String aMessage, Throwable aThrowable) {
|
||||
logger.fatal(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel the message to be logged
|
||||
*/
|
||||
static public void setLevel(int aLevel) {
|
||||
logger.setLevel(aLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Log.java,v $
|
||||
* Revision 1.5 2007/12/07 12:57:40 justb
|
||||
* added log4j and make it the default logging method
|
||||
*
|
||||
* Revision 1.4 2007/11/23 21:29:43 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
* Revision 1.3 2007/11/23 21:10:17 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:15:59 justb
|
||||
* support log levels
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/12 13:16:08 justb
|
||||
* make debug flag false
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 09:54:46 justb
|
||||
* fix javadoc warnings
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/08/12 09:42:47 justb
|
||||
* enhancements
|
||||
*
|
||||
* Revision 1.1 2003/08/12 08:46:00 justb
|
||||
* cvs comment tags added
|
||||
*
|
||||
*
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import nl.justobjects.pushlet.core.Config;
|
||||
import nl.justobjects.pushlet.core.ConfigDefs;
|
||||
|
||||
/**
|
||||
* Logging wrapper.
|
||||
* <p/>
|
||||
* Provides a hook to direct logging to your own logging library. Override the DefaultLogger class by setting
|
||||
* "logger.class" in pushlet.properties to your own logger
|
||||
* to integrate your own logging library.
|
||||
*
|
||||
* @author Just van den Broecke
|
||||
* @version $Id: Log.java,v 1.5 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class Log implements ConfigDefs {
|
||||
/**
|
||||
* Init with default to have at least some logging.
|
||||
*/
|
||||
private static PushletLogger logger = new DefaultLogger();
|
||||
|
||||
/**
|
||||
* General purpose initialization.
|
||||
*/
|
||||
static public void init() {
|
||||
try {
|
||||
logger = (PushletLogger) Config.getClass(LOGGER_CLASS, "nl.justobjects.pushlet.util.DefaultLogger").newInstance();
|
||||
} catch (Throwable t) {
|
||||
// Hmmm cannot log this since we don't have a log...
|
||||
System.out.println("Cannot instantiate Logger from config ex=" + t);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.init();
|
||||
|
||||
// Set log level
|
||||
logger.setLevel(Config.getIntProperty(Config.LOG_LEVEL));
|
||||
|
||||
logger.info("Logging intialized logger class=" + logger.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void trace(String aMessage) {
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void debug(String aMessage) {
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void info(String aMessage) {
|
||||
logger.info(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void warn(String aMessage) {
|
||||
logger.warn(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void warn(String aMessage, Throwable aThrowable) {
|
||||
logger.warn(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void error(String aMessage) {
|
||||
logger.error(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void error(String aMessage, Throwable aThrowable) {
|
||||
logger.error(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
static public void fatal(String aMessage) {
|
||||
logger.fatal(aMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
static public void fatal(String aMessage, Throwable aThrowable) {
|
||||
logger.fatal(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel the message to be logged
|
||||
*/
|
||||
static public void setLevel(int aLevel) {
|
||||
logger.setLevel(aLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Log.java,v $
|
||||
* Revision 1.5 2007/12/07 12:57:40 justb
|
||||
* added log4j and make it the default logging method
|
||||
*
|
||||
* Revision 1.4 2007/11/23 21:29:43 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
* Revision 1.3 2007/11/23 21:10:17 justb
|
||||
* add hooks for custom logging (you can override DefaultLogger in pushlet.properties)
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:15:59 justb
|
||||
* support log levels
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/12 13:16:08 justb
|
||||
* make debug flag false
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 09:54:46 justb
|
||||
* fix javadoc warnings
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/08/12 09:42:47 justb
|
||||
* enhancements
|
||||
*
|
||||
* Revision 1.1 2003/08/12 08:46:00 justb
|
||||
* cvs comment tags added
|
||||
*
|
||||
*
|
||||
*/
|
||||
+134
-134
@@ -1,134 +1,134 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Logger to use Log4j for logging.
|
||||
* <p/>
|
||||
* Logs using Log4j.
|
||||
* This class will require a log4j library in the classpath of the Pushlet.
|
||||
*
|
||||
* @author Uli Romahn
|
||||
* @version $Id: Log4jLogger.java,v 1.1 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class Log4jLogger implements PushletLogger {
|
||||
|
||||
/**
|
||||
* Level intialized with default.
|
||||
*/
|
||||
private Logger logger = LogManager.getLogger("pushlet");
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#init()
|
||||
*/
|
||||
public void init() {
|
||||
setLevel(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#debug(java.lang.String)
|
||||
*/
|
||||
public void debug(String aMessage) {
|
||||
if (!logger.isDebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#error(java.lang.String)
|
||||
*/
|
||||
public void error(String aMessage) {
|
||||
logger.error(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#error(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable) {
|
||||
logger.error(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#fatal(java.lang.String)
|
||||
*/
|
||||
public void fatal(String aMessage) {
|
||||
logger.fatal(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#fatal(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable) {
|
||||
logger.fatal(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#info(java.lang.String)
|
||||
*/
|
||||
public void info(String aMessage) {
|
||||
if (!logger.isInfoEnabled()) {
|
||||
return;
|
||||
}
|
||||
logger.info(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#trace(java.lang.String)
|
||||
*/
|
||||
public void trace(String aMessage) {
|
||||
logger.trace(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#warn(java.lang.String)
|
||||
*/
|
||||
public void warn(String aMessage) {
|
||||
logger.warn(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#warn(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable) {
|
||||
logger.warn(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#setLevel(int)
|
||||
*/
|
||||
public void setLevel(int aLevel) {
|
||||
if (aLevel < LOG_LEVEL_FATAL) {
|
||||
logger.setLevel(Level.OFF);
|
||||
} else {
|
||||
switch (aLevel) {
|
||||
case LOG_LEVEL_FATAL:
|
||||
logger.setLevel(Level.FATAL);
|
||||
break;
|
||||
case LOG_LEVEL_ERROR:
|
||||
logger.setLevel(Level.ERROR);
|
||||
break;
|
||||
case LOG_LEVEL_WARN:
|
||||
logger.setLevel(Level.WARN);
|
||||
break;
|
||||
case LOG_LEVEL_INFO:
|
||||
logger.setLevel(Level.INFO);
|
||||
break;
|
||||
case LOG_LEVEL_DEBUG:
|
||||
logger.setLevel(Level.DEBUG);
|
||||
break;
|
||||
case LOG_LEVEL_TRACE:
|
||||
logger.setLevel(Level.TRACE);
|
||||
break;
|
||||
default:
|
||||
logger.setLevel(Level.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Logger to use Log4j for logging.
|
||||
* <p/>
|
||||
* Logs using Log4j.
|
||||
* This class will require a log4j library in the classpath of the Pushlet.
|
||||
*
|
||||
* @author Uli Romahn
|
||||
* @version $Id: Log4jLogger.java,v 1.1 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public class Log4jLogger implements PushletLogger {
|
||||
|
||||
/**
|
||||
* Level intialized with default.
|
||||
*/
|
||||
private Logger logger = LogManager.getLogger("pushlet");
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#init()
|
||||
*/
|
||||
public void init() {
|
||||
setLevel(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#debug(java.lang.String)
|
||||
*/
|
||||
public void debug(String aMessage) {
|
||||
if (!logger.isDebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
logger.debug(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#error(java.lang.String)
|
||||
*/
|
||||
public void error(String aMessage) {
|
||||
logger.error(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#error(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable) {
|
||||
logger.error(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#fatal(java.lang.String)
|
||||
*/
|
||||
public void fatal(String aMessage) {
|
||||
logger.fatal(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#fatal(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable) {
|
||||
logger.fatal(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#info(java.lang.String)
|
||||
*/
|
||||
public void info(String aMessage) {
|
||||
if (!logger.isInfoEnabled()) {
|
||||
return;
|
||||
}
|
||||
logger.info(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#trace(java.lang.String)
|
||||
*/
|
||||
public void trace(String aMessage) {
|
||||
logger.trace(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#warn(java.lang.String)
|
||||
*/
|
||||
public void warn(String aMessage) {
|
||||
logger.warn(aMessage);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#warn(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable) {
|
||||
logger.warn(aMessage, aThrowable);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see nl.justobjects.pushlet.util.PushletLogger#setLevel(int)
|
||||
*/
|
||||
public void setLevel(int aLevel) {
|
||||
if (aLevel < LOG_LEVEL_FATAL) {
|
||||
logger.setLevel(Level.OFF);
|
||||
} else {
|
||||
switch (aLevel) {
|
||||
case LOG_LEVEL_FATAL:
|
||||
logger.setLevel(Level.FATAL);
|
||||
break;
|
||||
case LOG_LEVEL_ERROR:
|
||||
logger.setLevel(Level.ERROR);
|
||||
break;
|
||||
case LOG_LEVEL_WARN:
|
||||
logger.setLevel(Level.WARN);
|
||||
break;
|
||||
case LOG_LEVEL_INFO:
|
||||
logger.setLevel(Level.INFO);
|
||||
break;
|
||||
case LOG_LEVEL_DEBUG:
|
||||
logger.setLevel(Level.DEBUG);
|
||||
break;
|
||||
case LOG_LEVEL_TRACE:
|
||||
logger.setLevel(Level.TRACE);
|
||||
break;
|
||||
default:
|
||||
logger.setLevel(Level.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+94
-94
@@ -1,94 +1,94 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import nl.justobjects.pushlet.core.ConfigDefs;
|
||||
|
||||
/**
|
||||
* Logger interface to allow different logging providers.
|
||||
* <p/>
|
||||
*
|
||||
* @author Ulrich Romahn
|
||||
* @version $Id: PushletLogger.java,v 1.1 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public interface PushletLogger extends ConfigDefs {
|
||||
|
||||
/**
|
||||
* Method allowing to initialize our logger
|
||||
*/
|
||||
public void init();
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void trace(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void debug(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void info(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void warn(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void error(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void fatal(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel a valid Level from ConfigDefs
|
||||
*/
|
||||
public void setLevel(int aLevel);
|
||||
}
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.util;
|
||||
|
||||
import nl.justobjects.pushlet.core.ConfigDefs;
|
||||
|
||||
/**
|
||||
* Logger interface to allow different logging providers.
|
||||
* <p/>
|
||||
*
|
||||
* @author Ulrich Romahn
|
||||
* @version $Id: PushletLogger.java,v 1.1 2007/12/07 12:57:40 justb Exp $
|
||||
*/
|
||||
public interface PushletLogger extends ConfigDefs {
|
||||
|
||||
/**
|
||||
* Method allowing to initialize our logger
|
||||
*/
|
||||
public void init();
|
||||
|
||||
/**
|
||||
* Log message for trace level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void trace(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for debug level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void debug(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for info level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void info(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for warning level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void warn(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message for warning level with exception.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void warn(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Log message for error level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void error(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message (error level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void error(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Log message for fatal level.
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
*/
|
||||
public void fatal(String aMessage);
|
||||
|
||||
/**
|
||||
* Log message (fatal level with exception).
|
||||
*
|
||||
* @param aMessage the message to be logged
|
||||
* @param aThrowable the exception
|
||||
*/
|
||||
public void fatal(String aMessage, Throwable aThrowable);
|
||||
|
||||
/**
|
||||
* Set log level
|
||||
*
|
||||
* @param aLevel a valid Level from ConfigDefs
|
||||
*/
|
||||
public void setLevel(int aLevel);
|
||||
}
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
package pow.ivyclient;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
/**
|
||||
* inner representation of an ivy bus
|
||||
* store the drones' information about the drones which belong to this ivy bus
|
||||
* store the IP adress of the machine where the ivy bus is working
|
||||
*/
|
||||
public class BusIvy_
|
||||
{
|
||||
private Calendar oCalendar;
|
||||
private long oTime;
|
||||
private InetAddress busAddress;
|
||||
private ArrayList<Integer> DronesId = new ArrayList<Integer>();
|
||||
/**
|
||||
*
|
||||
* @param myInetAddress the ip address of the ivy host
|
||||
*/
|
||||
public void setAddress(InetAddress myInetAddress)
|
||||
{
|
||||
busAddress = myInetAddress;
|
||||
}
|
||||
/**
|
||||
* update the 'inner clock' of the object when a message for this bus is detected
|
||||
* useful to know if the bus is still alive
|
||||
*/
|
||||
public void updateTime()
|
||||
{
|
||||
oCalendar=Calendar.getInstance();
|
||||
oTime = oCalendar.getTimeInMillis();
|
||||
}
|
||||
/**
|
||||
* inform the bus that a new drone send information on this bus
|
||||
* @param newDroneId (the ivy id)
|
||||
*/
|
||||
public void addDrones(int newDroneId)
|
||||
{
|
||||
DronesId.add(newDroneId);
|
||||
}
|
||||
/**
|
||||
* get a array list containing the ivy id of the drones present on the bus
|
||||
* @return the array list containing the ivy id of the drones present on the bus
|
||||
*/
|
||||
public ArrayList<Integer> getDrones()
|
||||
{
|
||||
return DronesId;
|
||||
}
|
||||
/**
|
||||
* display information on stdout about the drones present on the bus
|
||||
*/
|
||||
public void displayDrones()
|
||||
{
|
||||
System.out.println("Bus Ivy : ");
|
||||
System.out.println(busAddress);
|
||||
System.out.println("Drones : ");
|
||||
for(Integer myDrone : DronesId)
|
||||
{
|
||||
System.out.println(myDrone);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* provides the IP adress of the host hosting the bus
|
||||
* @return the IP adress of the host hosting the bus
|
||||
*/
|
||||
public InetAddress getAddress()
|
||||
{
|
||||
return busAddress;
|
||||
}
|
||||
/**
|
||||
* inform if a drone is present or not on the bus
|
||||
* @param myDroneId the ivy id
|
||||
* @return true if the drone is present on the bus
|
||||
*/
|
||||
public boolean isOwnBy(int myDroneId)
|
||||
{
|
||||
return DronesId.contains(myDroneId);
|
||||
}
|
||||
/**
|
||||
* inform if the bus is alive
|
||||
* @return true if the last message was received less than 10 seconds ago
|
||||
*/
|
||||
public boolean isAlive()
|
||||
{
|
||||
Calendar iCalendar = Calendar.getInstance();
|
||||
long iTime = iCalendar.getTimeInMillis();
|
||||
|
||||
return ((iTime - oTime)<10000); // 10 secondes
|
||||
}
|
||||
package pow.ivyclient;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
/**
|
||||
* inner representation of an ivy bus
|
||||
* store the drones' information about the drones which belong to this ivy bus
|
||||
* store the IP adress of the machine where the ivy bus is working
|
||||
*/
|
||||
public class BusIvy_
|
||||
{
|
||||
private Calendar oCalendar;
|
||||
private long oTime;
|
||||
private InetAddress busAddress;
|
||||
private ArrayList<Integer> DronesId = new ArrayList<Integer>();
|
||||
/**
|
||||
*
|
||||
* @param myInetAddress the ip address of the ivy host
|
||||
*/
|
||||
public void setAddress(InetAddress myInetAddress)
|
||||
{
|
||||
busAddress = myInetAddress;
|
||||
}
|
||||
/**
|
||||
* update the 'inner clock' of the object when a message for this bus is detected
|
||||
* useful to know if the bus is still alive
|
||||
*/
|
||||
public void updateTime()
|
||||
{
|
||||
oCalendar=Calendar.getInstance();
|
||||
oTime = oCalendar.getTimeInMillis();
|
||||
}
|
||||
/**
|
||||
* inform the bus that a new drone send information on this bus
|
||||
* @param newDroneId (the ivy id)
|
||||
*/
|
||||
public void addDrones(int newDroneId)
|
||||
{
|
||||
DronesId.add(newDroneId);
|
||||
}
|
||||
/**
|
||||
* get a array list containing the ivy id of the drones present on the bus
|
||||
* @return the array list containing the ivy id of the drones present on the bus
|
||||
*/
|
||||
public ArrayList<Integer> getDrones()
|
||||
{
|
||||
return DronesId;
|
||||
}
|
||||
/**
|
||||
* display information on stdout about the drones present on the bus
|
||||
*/
|
||||
public void displayDrones()
|
||||
{
|
||||
System.out.println("Bus Ivy : ");
|
||||
System.out.println(busAddress);
|
||||
System.out.println("Drones : ");
|
||||
for(Integer myDrone : DronesId)
|
||||
{
|
||||
System.out.println(myDrone);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* provides the IP adress of the host hosting the bus
|
||||
* @return the IP adress of the host hosting the bus
|
||||
*/
|
||||
public InetAddress getAddress()
|
||||
{
|
||||
return busAddress;
|
||||
}
|
||||
/**
|
||||
* inform if a drone is present or not on the bus
|
||||
* @param myDroneId the ivy id
|
||||
* @return true if the drone is present on the bus
|
||||
*/
|
||||
public boolean isOwnBy(int myDroneId)
|
||||
{
|
||||
return DronesId.contains(myDroneId);
|
||||
}
|
||||
/**
|
||||
* inform if the bus is alive
|
||||
* @return true if the last message was received less than 10 seconds ago
|
||||
*/
|
||||
public boolean isAlive()
|
||||
{
|
||||
Calendar iCalendar = Calendar.getInstance();
|
||||
long iTime = iCalendar.getTimeInMillis();
|
||||
|
||||
return ((iTime - oTime)<10000); // 10 secondes
|
||||
}
|
||||
}
|
||||
@@ -1,165 +1,165 @@
|
||||
package pow.webserver;
|
||||
import java.io.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
/**
|
||||
*
|
||||
* store useful data about the server configuration
|
||||
* and database connection by
|
||||
* reading a specific file place in the 'conf' folder of
|
||||
* the web application
|
||||
*/
|
||||
public class Conf {
|
||||
/** The mail of the administrator to contact if any problems occurs
|
||||
* (appears in the help.jsp page. */
|
||||
private String mailAdmin;
|
||||
/** The administrator login (not used). */
|
||||
private String adminLogin;
|
||||
/** The port in which the module listen to get udp trames from ivy buses. */
|
||||
private int portIvyToWeb;
|
||||
/** The dimension of the datagrams received. */
|
||||
private int tailleUdpTrame;
|
||||
/** The passWord of the database */
|
||||
private String dbPassword;
|
||||
/** The userName of the dataBase */
|
||||
private String dbUserName;
|
||||
/** The Name of the dataBase */
|
||||
private String dataBaseName;
|
||||
/** The timeout of the connection */
|
||||
private int udpTimeout;
|
||||
/** The port in which messages from web are sent to ivy buses */
|
||||
private int portWebToIvy ;
|
||||
/** period of time in millisec to reset the filter of waypoint_moved messages */
|
||||
private long time2resetFilter;
|
||||
/** period of time in millisec to send all the parameter values for a specific drone */
|
||||
private long timeToSendValues;
|
||||
/** time to wait for the acknowledgement of an order */
|
||||
private int order_response_timeout;
|
||||
/** time to wait after a die event to remove the drone */
|
||||
private int dieEventTimeoutTime;
|
||||
/** time to wait after receiving no data for a drone to remove the drone */
|
||||
private int dataEventTimeoutTime;
|
||||
/** period of time to check for dead ivy buses in serveur.java*/
|
||||
private long time2checkDeadBuses;
|
||||
/** how the database work VERBOSE or SILENT*/
|
||||
private DbMode dbMode;
|
||||
/**
|
||||
*
|
||||
* @param default_folder folder of the web application on the server
|
||||
* @param conf_filename name of the configuration file placed in 'conf' folder of the web application
|
||||
*/
|
||||
public Conf(String default_folder,String conf_filename)
|
||||
{
|
||||
try{
|
||||
DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
|
||||
// création d'un constructeur de documents
|
||||
DocumentBuilder constructeur = fabrique.newDocumentBuilder();
|
||||
// lecture du contenu d'un fichier XML avec DOM
|
||||
File xml = new File(default_folder + "/conf/"+conf_filename);
|
||||
Document document = constructeur.parse(xml);
|
||||
Element mailAdmin_node = (Element)document.getElementsByTagName("mailWebAdmin").item(0);
|
||||
Element adminLogin_node = (Element)document.getElementsByTagName("webAdminLogin").item(0);
|
||||
Element portIvyToWeb_node = (Element)document.getElementsByTagName("portIvyToWeb").item(0);
|
||||
Element taille_node = (Element)document.getElementsByTagName("sizeUdpTrame").item(0);
|
||||
Element passWord_node = (Element)document.getElementsByTagName("dbPassword").item(0);
|
||||
Element userName_node = (Element)document.getElementsByTagName("dbUserName").item(0);
|
||||
Element dataBaseName_node = (Element)document.getElementsByTagName("dataBaseName").item(0);
|
||||
Element timeout_node = (Element)document.getElementsByTagName("udpSocketTimeout").item(0);
|
||||
Element portWebToIvy_node = (Element)document.getElementsByTagName("portWebToIvy").item(0);
|
||||
Element time2resetFilter_node = (Element)document.getElementsByTagName("time2resetFilter").item(0);
|
||||
Element timeToSendValuesy_node = (Element)document.getElementsByTagName("timeToSendValues").item(0);
|
||||
Element order_response_timeout_node = (Element)document.getElementsByTagName("order_response_timeout").item(0);
|
||||
Element dieEventTimeoutTime_node = (Element)document.getElementsByTagName("dieEventTimeoutTime").item(0);
|
||||
Element dataEventTimeoutTime_node = (Element)document.getElementsByTagName("dataEventTimeoutTime").item(0);
|
||||
Element time2checkDeadBuses_node = (Element)document.getElementsByTagName("time2checkDeadBuses").item(0);
|
||||
|
||||
Element dbMode_node = (Element)document.getElementsByTagName("dbMode").item(0);
|
||||
String dbMode_str = dbMode_node.getTextContent();
|
||||
if (dbMode_str.equals("verbose")){dbMode = DbMode.VERBOSE;}
|
||||
else {dbMode = DbMode.SILENT;}
|
||||
mailAdmin=mailAdmin_node.getTextContent();
|
||||
adminLogin=adminLogin_node.getTextContent();
|
||||
portIvyToWeb=Integer.parseInt(portIvyToWeb_node.getTextContent());
|
||||
tailleUdpTrame=Integer.parseInt(taille_node.getTextContent());
|
||||
dbPassword=passWord_node.getTextContent();
|
||||
dbUserName=userName_node.getTextContent();
|
||||
dataBaseName=dataBaseName_node.getTextContent();
|
||||
udpTimeout=Integer.parseInt(timeout_node.getTextContent());
|
||||
portWebToIvy=Integer.parseInt(portWebToIvy_node.getTextContent());
|
||||
time2resetFilter=Long.parseLong(time2resetFilter_node.getTextContent());
|
||||
timeToSendValues=Long.parseLong(timeToSendValuesy_node.getTextContent());
|
||||
order_response_timeout=Integer.parseInt(order_response_timeout_node.getTextContent());
|
||||
dieEventTimeoutTime=Integer.parseInt(dieEventTimeoutTime_node.getTextContent());
|
||||
dataEventTimeoutTime=Integer.parseInt(dataEventTimeoutTime_node.getTextContent());
|
||||
time2checkDeadBuses =Integer.parseInt(time2checkDeadBuses_node.getTextContent());
|
||||
} catch(ParserConfigurationException pce){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
pce.printStackTrace();
|
||||
}catch(SAXException se){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
se.printStackTrace();
|
||||
}catch(IOException ioe){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
/** @return the udp port on which the server receive data from ivy buses */
|
||||
public int portIvyToWeb()
|
||||
{
|
||||
return portIvyToWeb;
|
||||
}
|
||||
/** @return the udp port on which the server send data to ivy buses */
|
||||
public int portWebToIvy()
|
||||
{
|
||||
return portWebToIvy;
|
||||
}
|
||||
/** @return the max size of an udp trame */
|
||||
public int getUdpSize()
|
||||
{
|
||||
return tailleUdpTrame;
|
||||
}
|
||||
/** @return the password to connect to the database*/
|
||||
public String getDBPassword()
|
||||
{
|
||||
return dbPassword;
|
||||
}
|
||||
/** @return the login to connect to the database*/
|
||||
public String getDBUserName()
|
||||
{
|
||||
return dbUserName;
|
||||
}
|
||||
/** @return the database name*/
|
||||
public String getDataBaseName()
|
||||
{
|
||||
return dataBaseName;
|
||||
}
|
||||
/** @return a time after what an exception is thrown if no message has been received by server*/
|
||||
public int getSocketTimeout()
|
||||
{
|
||||
return udpTimeout;
|
||||
}
|
||||
/** @return the mail to contact if any problem occurs */
|
||||
public String mailAdmin(){return mailAdmin;}
|
||||
/** @return the login of the administrator of the site */
|
||||
public String adminLogin(){return adminLogin;}
|
||||
/**@return period of time in millisec to reset the filter of waypoint_moved messages */
|
||||
public long getTime2resetFilter(){return time2resetFilter;}
|
||||
/**@return period of time in millisec to send all the parameter values for a specific drone */
|
||||
public long getTimeToSendValues(){return timeToSendValues;}
|
||||
/**@return time to wait for the acknowledgement of an order */
|
||||
public int getOrderResponseTimeout(){return order_response_timeout;}
|
||||
/**@return time to wait after a die event to remove the drone */
|
||||
public int getDieEventTimeoutTime(){return dieEventTimeoutTime;}
|
||||
/**@return time to wait after receiving no data for a drone to remove the drone */
|
||||
public int getDataEventTimeoutTime(){return dataEventTimeoutTime;}
|
||||
/**@return period of time to check for dead ivy buses in serveur.java*/
|
||||
public long getTime2checkDeadBuses(){return time2checkDeadBuses;}
|
||||
/**@return SILENT or VERBOSE */
|
||||
public DbMode getDbMode(){return dbMode;}
|
||||
package pow.webserver;
|
||||
import java.io.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
/**
|
||||
*
|
||||
* store useful data about the server configuration
|
||||
* and database connection by
|
||||
* reading a specific file place in the 'conf' folder of
|
||||
* the web application
|
||||
*/
|
||||
public class Conf {
|
||||
/** The mail of the administrator to contact if any problems occurs
|
||||
* (appears in the help.jsp page. */
|
||||
private String mailAdmin;
|
||||
/** The administrator login (not used). */
|
||||
private String adminLogin;
|
||||
/** The port in which the module listen to get udp trames from ivy buses. */
|
||||
private int portIvyToWeb;
|
||||
/** The dimension of the datagrams received. */
|
||||
private int tailleUdpTrame;
|
||||
/** The passWord of the database */
|
||||
private String dbPassword;
|
||||
/** The userName of the dataBase */
|
||||
private String dbUserName;
|
||||
/** The Name of the dataBase */
|
||||
private String dataBaseName;
|
||||
/** The timeout of the connection */
|
||||
private int udpTimeout;
|
||||
/** The port in which messages from web are sent to ivy buses */
|
||||
private int portWebToIvy ;
|
||||
/** period of time in millisec to reset the filter of waypoint_moved messages */
|
||||
private long time2resetFilter;
|
||||
/** period of time in millisec to send all the parameter values for a specific drone */
|
||||
private long timeToSendValues;
|
||||
/** time to wait for the acknowledgement of an order */
|
||||
private int order_response_timeout;
|
||||
/** time to wait after a die event to remove the drone */
|
||||
private int dieEventTimeoutTime;
|
||||
/** time to wait after receiving no data for a drone to remove the drone */
|
||||
private int dataEventTimeoutTime;
|
||||
/** period of time to check for dead ivy buses in serveur.java*/
|
||||
private long time2checkDeadBuses;
|
||||
/** how the database work VERBOSE or SILENT*/
|
||||
private DbMode dbMode;
|
||||
/**
|
||||
*
|
||||
* @param default_folder folder of the web application on the server
|
||||
* @param conf_filename name of the configuration file placed in 'conf' folder of the web application
|
||||
*/
|
||||
public Conf(String default_folder,String conf_filename)
|
||||
{
|
||||
try{
|
||||
DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
|
||||
// création d'un constructeur de documents
|
||||
DocumentBuilder constructeur = fabrique.newDocumentBuilder();
|
||||
// lecture du contenu d'un fichier XML avec DOM
|
||||
File xml = new File(default_folder + "/conf/"+conf_filename);
|
||||
Document document = constructeur.parse(xml);
|
||||
Element mailAdmin_node = (Element)document.getElementsByTagName("mailWebAdmin").item(0);
|
||||
Element adminLogin_node = (Element)document.getElementsByTagName("webAdminLogin").item(0);
|
||||
Element portIvyToWeb_node = (Element)document.getElementsByTagName("portIvyToWeb").item(0);
|
||||
Element taille_node = (Element)document.getElementsByTagName("sizeUdpTrame").item(0);
|
||||
Element passWord_node = (Element)document.getElementsByTagName("dbPassword").item(0);
|
||||
Element userName_node = (Element)document.getElementsByTagName("dbUserName").item(0);
|
||||
Element dataBaseName_node = (Element)document.getElementsByTagName("dataBaseName").item(0);
|
||||
Element timeout_node = (Element)document.getElementsByTagName("udpSocketTimeout").item(0);
|
||||
Element portWebToIvy_node = (Element)document.getElementsByTagName("portWebToIvy").item(0);
|
||||
Element time2resetFilter_node = (Element)document.getElementsByTagName("time2resetFilter").item(0);
|
||||
Element timeToSendValuesy_node = (Element)document.getElementsByTagName("timeToSendValues").item(0);
|
||||
Element order_response_timeout_node = (Element)document.getElementsByTagName("order_response_timeout").item(0);
|
||||
Element dieEventTimeoutTime_node = (Element)document.getElementsByTagName("dieEventTimeoutTime").item(0);
|
||||
Element dataEventTimeoutTime_node = (Element)document.getElementsByTagName("dataEventTimeoutTime").item(0);
|
||||
Element time2checkDeadBuses_node = (Element)document.getElementsByTagName("time2checkDeadBuses").item(0);
|
||||
|
||||
Element dbMode_node = (Element)document.getElementsByTagName("dbMode").item(0);
|
||||
String dbMode_str = dbMode_node.getTextContent();
|
||||
if (dbMode_str.equals("verbose")){dbMode = DbMode.VERBOSE;}
|
||||
else {dbMode = DbMode.SILENT;}
|
||||
mailAdmin=mailAdmin_node.getTextContent();
|
||||
adminLogin=adminLogin_node.getTextContent();
|
||||
portIvyToWeb=Integer.parseInt(portIvyToWeb_node.getTextContent());
|
||||
tailleUdpTrame=Integer.parseInt(taille_node.getTextContent());
|
||||
dbPassword=passWord_node.getTextContent();
|
||||
dbUserName=userName_node.getTextContent();
|
||||
dataBaseName=dataBaseName_node.getTextContent();
|
||||
udpTimeout=Integer.parseInt(timeout_node.getTextContent());
|
||||
portWebToIvy=Integer.parseInt(portWebToIvy_node.getTextContent());
|
||||
time2resetFilter=Long.parseLong(time2resetFilter_node.getTextContent());
|
||||
timeToSendValues=Long.parseLong(timeToSendValuesy_node.getTextContent());
|
||||
order_response_timeout=Integer.parseInt(order_response_timeout_node.getTextContent());
|
||||
dieEventTimeoutTime=Integer.parseInt(dieEventTimeoutTime_node.getTextContent());
|
||||
dataEventTimeoutTime=Integer.parseInt(dataEventTimeoutTime_node.getTextContent());
|
||||
time2checkDeadBuses =Integer.parseInt(time2checkDeadBuses_node.getTextContent());
|
||||
} catch(ParserConfigurationException pce){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
pce.printStackTrace();
|
||||
}catch(SAXException se){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
se.printStackTrace();
|
||||
}catch(IOException ioe){
|
||||
System.out.println("error in loading configuration file : "+default_folder + "/conf/"+conf_filename);
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
/** @return the udp port on which the server receive data from ivy buses */
|
||||
public int portIvyToWeb()
|
||||
{
|
||||
return portIvyToWeb;
|
||||
}
|
||||
/** @return the udp port on which the server send data to ivy buses */
|
||||
public int portWebToIvy()
|
||||
{
|
||||
return portWebToIvy;
|
||||
}
|
||||
/** @return the max size of an udp trame */
|
||||
public int getUdpSize()
|
||||
{
|
||||
return tailleUdpTrame;
|
||||
}
|
||||
/** @return the password to connect to the database*/
|
||||
public String getDBPassword()
|
||||
{
|
||||
return dbPassword;
|
||||
}
|
||||
/** @return the login to connect to the database*/
|
||||
public String getDBUserName()
|
||||
{
|
||||
return dbUserName;
|
||||
}
|
||||
/** @return the database name*/
|
||||
public String getDataBaseName()
|
||||
{
|
||||
return dataBaseName;
|
||||
}
|
||||
/** @return a time after what an exception is thrown if no message has been received by server*/
|
||||
public int getSocketTimeout()
|
||||
{
|
||||
return udpTimeout;
|
||||
}
|
||||
/** @return the mail to contact if any problem occurs */
|
||||
public String mailAdmin(){return mailAdmin;}
|
||||
/** @return the login of the administrator of the site */
|
||||
public String adminLogin(){return adminLogin;}
|
||||
/**@return period of time in millisec to reset the filter of waypoint_moved messages */
|
||||
public long getTime2resetFilter(){return time2resetFilter;}
|
||||
/**@return period of time in millisec to send all the parameter values for a specific drone */
|
||||
public long getTimeToSendValues(){return timeToSendValues;}
|
||||
/**@return time to wait for the acknowledgement of an order */
|
||||
public int getOrderResponseTimeout(){return order_response_timeout;}
|
||||
/**@return time to wait after a die event to remove the drone */
|
||||
public int getDieEventTimeoutTime(){return dieEventTimeoutTime;}
|
||||
/**@return time to wait after receiving no data for a drone to remove the drone */
|
||||
public int getDataEventTimeoutTime(){return dataEventTimeoutTime;}
|
||||
/**@return period of time to check for dead ivy buses in serveur.java*/
|
||||
public long getTime2checkDeadBuses(){return time2checkDeadBuses;}
|
||||
/**@return SILENT or VERBOSE */
|
||||
public DbMode getDbMode(){return dbMode;}
|
||||
}
|
||||
@@ -1,73 +1,73 @@
|
||||
package pow.webserver;
|
||||
import java.io.*;
|
||||
import java.util.Calendar;
|
||||
/**
|
||||
* Handles the writing of a log in a file
|
||||
* @author from V1
|
||||
* @since V1
|
||||
*/
|
||||
public class Log {
|
||||
|
||||
private File oFile = null;
|
||||
private FileWriter oFileWriter = null;
|
||||
private BufferedWriter oBufferedWriter = null;
|
||||
/**
|
||||
* create a log file into the log floder of the web application
|
||||
* @param path the complete path of the web application
|
||||
*/
|
||||
public Log(String path)
|
||||
{
|
||||
Calendar Today = Calendar.getInstance();
|
||||
String fileName = String.valueOf(Today.get(Calendar.DAY_OF_MONTH)) +
|
||||
String.valueOf(Today.get(Calendar.MONTH)) +
|
||||
String.valueOf(Today.get(Calendar.YEAR)) +
|
||||
String.valueOf(Today.get(Calendar.HOUR_OF_DAY)) +
|
||||
String.valueOf(Today.get(Calendar.MINUTE)) +
|
||||
String.valueOf(Today.get(Calendar.SECOND)) +
|
||||
".log";
|
||||
|
||||
try
|
||||
{
|
||||
oFile = new File(path+"/log/" + fileName);
|
||||
oFile.createNewFile();
|
||||
oFileWriter = new FileWriter(oFile);
|
||||
oBufferedWriter = new BufferedWriter(oFileWriter);
|
||||
|
||||
oBufferedWriter.write("##########################################"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("########## PAPARAZZI ON THE WEB ##########"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("##########################################"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("Beginning of log : "); oBufferedWriter.newLine();
|
||||
oBufferedWriter.newLine();
|
||||
oBufferedWriter.flush();
|
||||
}
|
||||
catch(IOException ex)
|
||||
{
|
||||
System.out.println("No log file created ");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* write a string in log file and on stdout
|
||||
* @param writing the string to write in the log file
|
||||
*/
|
||||
public void write(String writing)
|
||||
{
|
||||
Calendar Now = Calendar.getInstance();
|
||||
String Time = String.valueOf(Now.get(Calendar.HOUR_OF_DAY)) + ":" +
|
||||
String.valueOf(Now.get(Calendar.MINUTE)) + ":" +
|
||||
String.valueOf(Now.get(Calendar.SECOND));
|
||||
writing = writing.trim();
|
||||
try
|
||||
{
|
||||
oBufferedWriter.write(Time + " -> " + writing); oBufferedWriter.newLine();
|
||||
oBufferedWriter.flush();
|
||||
System.out.println("\nlog at : " + Time + " -> " + writing);
|
||||
}
|
||||
catch(IOException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
package pow.webserver;
|
||||
import java.io.*;
|
||||
import java.util.Calendar;
|
||||
/**
|
||||
* Handles the writing of a log in a file
|
||||
* @author from V1
|
||||
* @since V1
|
||||
*/
|
||||
public class Log {
|
||||
|
||||
private File oFile = null;
|
||||
private FileWriter oFileWriter = null;
|
||||
private BufferedWriter oBufferedWriter = null;
|
||||
/**
|
||||
* create a log file into the log floder of the web application
|
||||
* @param path the complete path of the web application
|
||||
*/
|
||||
public Log(String path)
|
||||
{
|
||||
Calendar Today = Calendar.getInstance();
|
||||
String fileName = String.valueOf(Today.get(Calendar.DAY_OF_MONTH)) +
|
||||
String.valueOf(Today.get(Calendar.MONTH)) +
|
||||
String.valueOf(Today.get(Calendar.YEAR)) +
|
||||
String.valueOf(Today.get(Calendar.HOUR_OF_DAY)) +
|
||||
String.valueOf(Today.get(Calendar.MINUTE)) +
|
||||
String.valueOf(Today.get(Calendar.SECOND)) +
|
||||
".log";
|
||||
|
||||
try
|
||||
{
|
||||
oFile = new File(path+"/log/" + fileName);
|
||||
oFile.createNewFile();
|
||||
oFileWriter = new FileWriter(oFile);
|
||||
oBufferedWriter = new BufferedWriter(oFileWriter);
|
||||
|
||||
oBufferedWriter.write("##########################################"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("########## PAPARAZZI ON THE WEB ##########"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("##########################################"); oBufferedWriter.newLine();
|
||||
oBufferedWriter.newLine();
|
||||
oBufferedWriter.write("Beginning of log : "); oBufferedWriter.newLine();
|
||||
oBufferedWriter.newLine();
|
||||
oBufferedWriter.flush();
|
||||
}
|
||||
catch(IOException ex)
|
||||
{
|
||||
System.out.println("No log file created ");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* write a string in log file and on stdout
|
||||
* @param writing the string to write in the log file
|
||||
*/
|
||||
public void write(String writing)
|
||||
{
|
||||
Calendar Now = Calendar.getInstance();
|
||||
String Time = String.valueOf(Now.get(Calendar.HOUR_OF_DAY)) + ":" +
|
||||
String.valueOf(Now.get(Calendar.MINUTE)) + ":" +
|
||||
String.valueOf(Now.get(Calendar.SECOND));
|
||||
writing = writing.trim();
|
||||
try
|
||||
{
|
||||
oBufferedWriter.write(Time + " -> " + writing); oBufferedWriter.newLine();
|
||||
oBufferedWriter.flush();
|
||||
System.out.println("\nlog at : " + Time + " -> " + writing);
|
||||
}
|
||||
catch(IOException ex)
|
||||
{
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+698
-698
File diff suppressed because it is too large
Load Diff
+46
-46
@@ -1,50 +1,50 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.client;
|
||||
|
||||
import nl.justobjects.pushlet.core.Event;
|
||||
import nl.justobjects.pushlet.core.Protocol;
|
||||
|
||||
/**
|
||||
* Interface for listener of the PushletClient object.
|
||||
*
|
||||
* @version $Id: PushletClientListener.java,v 1.5 2005/02/21 11:50:37 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
public interface PushletClientListener extends Protocol {
|
||||
/** Abort event from server. */
|
||||
public void onAbort(Event theEvent);
|
||||
|
||||
/** Data event from server. */
|
||||
public void onData(Event theEvent);
|
||||
|
||||
/** Heartbeat event from server. */
|
||||
public void onHeartbeat(Event theEvent);
|
||||
|
||||
/** Error occurred. */
|
||||
public void onError(String message);
|
||||
}
|
||||
|
||||
/*
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.client;
|
||||
|
||||
import nl.justobjects.pushlet.core.Event;
|
||||
import nl.justobjects.pushlet.core.Protocol;
|
||||
|
||||
/**
|
||||
* Interface for listener of the PushletClient object.
|
||||
*
|
||||
* @version $Id: PushletClientListener.java,v 1.5 2005/02/21 11:50:37 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
public interface PushletClientListener extends Protocol {
|
||||
/** Abort event from server. */
|
||||
public void onAbort(Event theEvent);
|
||||
|
||||
/** Data event from server. */
|
||||
public void onData(Event theEvent);
|
||||
|
||||
/** Heartbeat event from server. */
|
||||
public void onHeartbeat(Event theEvent);
|
||||
|
||||
/** Error occurred. */
|
||||
public void onError(String message);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: PushletClientListener.java,v $
|
||||
* Revision 1.5 2005/02/21 11:50:37 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.4 2005/02/15 15:46:31 justb
|
||||
* client API improves
|
||||
*
|
||||
* Revision 1.3 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.2 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.1 2004/03/10 20:14:17 justb
|
||||
* renamed all *JavaPushletClient* to *PushletClient*
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
*
|
||||
*
|
||||
* Revision 1.4 2005/02/15 15:46:31 justb
|
||||
* client API improves
|
||||
*
|
||||
* Revision 1.3 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.2 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.1 2004/03/10 20:14:17 justb
|
||||
* renamed all *JavaPushletClient* to *PushletClient*
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
*
|
||||
*/
|
||||
+203
-203
@@ -1,203 +1,203 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Generic implementation of ClientAdapter for browser clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: BrowserAdapter.java,v 1.6 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
public class BrowserAdapter implements ClientAdapter, Protocol {
|
||||
|
||||
public static final String START_DOCUMENT =
|
||||
"<html><head><meta http-equiv=\"Pragma\" content=\"no-cache\"><meta http-equiv=\"Expires\" content=\"Tue, 31 Dec 1997 23:59:59 GMT\"></head>"
|
||||
+ "<body>"
|
||||
+ "\n<script language=\"JavaScript\"> var url=\" \"; \nfunction refresh() { document.location.href=url; }</script>";
|
||||
public static final String END_DOCUMENT = "</body></html>";
|
||||
|
||||
private PrintWriter servletOut;
|
||||
private HttpServletResponse servletRsp;
|
||||
private int bytesSent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BrowserAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic init.
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
// Keep servlet request/response objects until page ends in stop()
|
||||
// Content type as HTML
|
||||
servletRsp.setStatus(HttpServletResponse.SC_OK);
|
||||
servletRsp.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
// http://www.junlu.com/msg/45902.html
|
||||
// Log.debug("bufsize=" + aRsp.getBufferSize());
|
||||
servletOut = servletRsp.getWriter();
|
||||
send(START_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
Log.debug("BCA event=" + anEvent.toXML());
|
||||
|
||||
// Check if we should refresh
|
||||
if (anEvent.getEventType().equals(Protocol.E_REFRESH)) {
|
||||
// Append refresh and tail of HTML document
|
||||
// Construct the JS callback line to be sent as last line of doc.
|
||||
// This will refresh the request using the unique id to determine
|
||||
// the subscriber instance on the server. The client will wait for
|
||||
// a number of milliseconds.
|
||||
long refreshWaitMillis = Long.parseLong(anEvent.getField(P_WAIT));
|
||||
|
||||
// Create servlet request for requesting next events (refresh)
|
||||
String url = anEvent.getField(P_URL);
|
||||
String jsRefreshTrigger = "\n<script language=\"JavaScript\">url=\'" + url + "\';\n setTimeout(\"refresh()\", " + refreshWaitMillis + ");\n</script>";
|
||||
|
||||
|
||||
send(jsRefreshTrigger + END_DOCUMENT);
|
||||
} else {
|
||||
send(event2JavaScript(anEvent));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End HTML page in client browser.
|
||||
*/
|
||||
public void stop() {
|
||||
// To be garbage collected if adapter remains active
|
||||
servletOut = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send any string to browser.
|
||||
*/
|
||||
protected void send(String s) throws IOException {
|
||||
// Send string to browser.
|
||||
// Log.debug("Adapter: sending: " + s);
|
||||
if (servletOut == null) {
|
||||
throw new IOException("Client adapter was stopped");
|
||||
}
|
||||
|
||||
servletOut.print(s);
|
||||
|
||||
servletOut.flush();
|
||||
|
||||
// Note: this doesn't seem to have effect
|
||||
// in Tomcat 4/5 if the client already disconnected.
|
||||
servletRsp.flushBuffer();
|
||||
|
||||
bytesSent += s.length();
|
||||
Log.debug("bytesSent= " + bytesSent);
|
||||
// Log.debug("BCA sent event: " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Java Event to a JavaScript function call in browser page.
|
||||
*/
|
||||
protected String event2JavaScript(Event event) throws IOException {
|
||||
|
||||
// Convert the event to a comma-separated string.
|
||||
String jsArgs = "";
|
||||
for (Iterator iter = event.getFieldNames(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String value = event.getField(name);
|
||||
String nextArgument = (jsArgs.equals("") ? "" : ",") + "'" + name + "'" + ", \"" + value + "\"";
|
||||
jsArgs += nextArgument;
|
||||
}
|
||||
|
||||
// Construct and return the function call */
|
||||
return "<script language=\"JavaScript\">parent.push(" + jsArgs + ");</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: BrowserAdapter.java,v $
|
||||
* Revision 1.6 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.5 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.4 2006/05/06 00:10:11 justb
|
||||
* various chgs but not too serious...
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:44 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.12 2005/02/15 13:30:23 justb
|
||||
* changes for Tomcat buffering (now working in tc4 and 5.0)
|
||||
*
|
||||
* Revision 1.11 2005/01/24 22:45:58 justb
|
||||
* getting safari to work
|
||||
*
|
||||
* Revision 1.10 2005/01/18 16:46:27 justb
|
||||
* buffer size setting ignored by tomcat workings
|
||||
*
|
||||
* Revision 1.9 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.5 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:07 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:02 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Generic implementation of ClientAdapter for browser clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: BrowserAdapter.java,v 1.6 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
public class BrowserAdapter implements ClientAdapter, Protocol {
|
||||
|
||||
public static final String START_DOCUMENT =
|
||||
"<html><head><meta http-equiv=\"Pragma\" content=\"no-cache\"><meta http-equiv=\"Expires\" content=\"Tue, 31 Dec 1997 23:59:59 GMT\"></head>"
|
||||
+ "<body>"
|
||||
+ "\n<script language=\"JavaScript\"> var url=\" \"; \nfunction refresh() { document.location.href=url; }</script>";
|
||||
public static final String END_DOCUMENT = "</body></html>";
|
||||
|
||||
private PrintWriter servletOut;
|
||||
private HttpServletResponse servletRsp;
|
||||
private int bytesSent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BrowserAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic init.
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
// Keep servlet request/response objects until page ends in stop()
|
||||
// Content type as HTML
|
||||
servletRsp.setStatus(HttpServletResponse.SC_OK);
|
||||
servletRsp.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
// http://www.junlu.com/msg/45902.html
|
||||
// Log.debug("bufsize=" + aRsp.getBufferSize());
|
||||
servletOut = servletRsp.getWriter();
|
||||
send(START_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
Log.debug("BCA event=" + anEvent.toXML());
|
||||
|
||||
// Check if we should refresh
|
||||
if (anEvent.getEventType().equals(Protocol.E_REFRESH)) {
|
||||
// Append refresh and tail of HTML document
|
||||
// Construct the JS callback line to be sent as last line of doc.
|
||||
// This will refresh the request using the unique id to determine
|
||||
// the subscriber instance on the server. The client will wait for
|
||||
// a number of milliseconds.
|
||||
long refreshWaitMillis = Long.parseLong(anEvent.getField(P_WAIT));
|
||||
|
||||
// Create servlet request for requesting next events (refresh)
|
||||
String url = anEvent.getField(P_URL);
|
||||
String jsRefreshTrigger = "\n<script language=\"JavaScript\">url=\'" + url + "\';\n setTimeout(\"refresh()\", " + refreshWaitMillis + ");\n</script>";
|
||||
|
||||
|
||||
send(jsRefreshTrigger + END_DOCUMENT);
|
||||
} else {
|
||||
send(event2JavaScript(anEvent));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End HTML page in client browser.
|
||||
*/
|
||||
public void stop() {
|
||||
// To be garbage collected if adapter remains active
|
||||
servletOut = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send any string to browser.
|
||||
*/
|
||||
protected void send(String s) throws IOException {
|
||||
// Send string to browser.
|
||||
// Log.debug("Adapter: sending: " + s);
|
||||
if (servletOut == null) {
|
||||
throw new IOException("Client adapter was stopped");
|
||||
}
|
||||
|
||||
servletOut.print(s);
|
||||
|
||||
servletOut.flush();
|
||||
|
||||
// Note: this doesn't seem to have effect
|
||||
// in Tomcat 4/5 if the client already disconnected.
|
||||
servletRsp.flushBuffer();
|
||||
|
||||
bytesSent += s.length();
|
||||
Log.debug("bytesSent= " + bytesSent);
|
||||
// Log.debug("BCA sent event: " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Java Event to a JavaScript function call in browser page.
|
||||
*/
|
||||
protected String event2JavaScript(Event event) throws IOException {
|
||||
|
||||
// Convert the event to a comma-separated string.
|
||||
String jsArgs = "";
|
||||
for (Iterator iter = event.getFieldNames(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String value = event.getField(name);
|
||||
String nextArgument = (jsArgs.equals("") ? "" : ",") + "'" + name + "'" + ", \"" + value + "\"";
|
||||
jsArgs += nextArgument;
|
||||
}
|
||||
|
||||
// Construct and return the function call */
|
||||
return "<script language=\"JavaScript\">parent.push(" + jsArgs + ");</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: BrowserAdapter.java,v $
|
||||
* Revision 1.6 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.5 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.4 2006/05/06 00:10:11 justb
|
||||
* various chgs but not too serious...
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:44 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.12 2005/02/15 13:30:23 justb
|
||||
* changes for Tomcat buffering (now working in tc4 and 5.0)
|
||||
*
|
||||
* Revision 1.11 2005/01/24 22:45:58 justb
|
||||
* getting safari to work
|
||||
*
|
||||
* Revision 1.10 2005/01/18 16:46:27 justb
|
||||
* buffer size setting ignored by tomcat workings
|
||||
*
|
||||
* Revision 1.9 2004/10/24 12:58:18 justb
|
||||
* revised client and test classes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.5 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:07 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:02 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+72
-72
@@ -1,72 +1,72 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Adapter interface for encapsulation of specific HTTP clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: ClientAdapter.java,v 1.8 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public interface ClientAdapter {
|
||||
|
||||
/**
|
||||
* Start event push.
|
||||
*/
|
||||
public void start() throws IOException;
|
||||
|
||||
/**
|
||||
* Push single Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException;
|
||||
|
||||
/**
|
||||
* Stop event push.
|
||||
*/
|
||||
public void stop() throws IOException;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: ClientAdapter.java,v $
|
||||
* Revision 1.8 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.7 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:45 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Adapter interface for encapsulation of specific HTTP clients.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: ClientAdapter.java,v 1.8 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public interface ClientAdapter {
|
||||
|
||||
/**
|
||||
* Start event push.
|
||||
*/
|
||||
public void start() throws IOException;
|
||||
|
||||
/**
|
||||
* Push single Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException;
|
||||
|
||||
/**
|
||||
* Stop event push.
|
||||
*/
|
||||
public void stop() throws IOException;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: ClientAdapter.java,v $
|
||||
* Revision 1.8 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.7 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:45 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+265
-265
File diff suppressed because it is too large
Load Diff
+184
-184
@@ -1,184 +1,184 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the event data.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: Event.java,v 1.13 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public class Event implements Protocol, Serializable {
|
||||
|
||||
protected Map attributes = new HashMap(3);
|
||||
|
||||
public Event(String anEventType) {
|
||||
this(anEventType, null);
|
||||
}
|
||||
|
||||
public Event(String anEventType, Map theAttributes) {
|
||||
|
||||
if (theAttributes != null) {
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
// Set required field event type
|
||||
setField(P_EVENT, anEventType);
|
||||
|
||||
// Set time in seconds since 1970
|
||||
setField(P_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public Event(Map theAttributes) {
|
||||
if (!theAttributes.containsKey(P_EVENT)) {
|
||||
throw new IllegalArgumentException(P_EVENT + " not found in attributes");
|
||||
}
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject) {
|
||||
return createDataEvent(aSubject, null);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject, Map theAttributes) {
|
||||
Event dataEvent = new Event(E_DATA, theAttributes);
|
||||
dataEvent.setField(P_SUBJECT, aSubject);
|
||||
return dataEvent;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return getField(P_EVENT);
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return getField(P_SUBJECT);
|
||||
}
|
||||
|
||||
public void setField(String name, String value) {
|
||||
attributes.put(name, value);
|
||||
}
|
||||
|
||||
public void setField(String name, int value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public void setField(String name, long value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public String getField(String name) {
|
||||
return (String) attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return field; if null return default.
|
||||
*/
|
||||
public String getField(String name, String aDefault) {
|
||||
String result = getField(name);
|
||||
return result == null ? aDefault : result;
|
||||
}
|
||||
|
||||
public Iterator getFieldNames() {
|
||||
return attributes.keySet().iterator();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return attributes.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to HTTP query string.
|
||||
*/
|
||||
public String toQueryString() {
|
||||
String queryString = "";
|
||||
String amp = "";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
queryString = queryString + amp + nextAttrName + "=" + nextAttrValue;
|
||||
// After first add "&".
|
||||
amp = "&";
|
||||
}
|
||||
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public String toXML(boolean strict) {
|
||||
String xmlString = "<event ";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
xmlString = xmlString + nextAttrName + "=\"" + (strict ? Sys.forHTMLTag(nextAttrValue) : nextAttrValue) + "\" ";
|
||||
}
|
||||
|
||||
xmlString += "/>";
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
return toXML(false);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
// Clone the Event by using copy constructor
|
||||
return new Event(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy given attributes into event attributes
|
||||
*/
|
||||
private void setAttrs(Map theAttributes) {
|
||||
attributes.putAll(theAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Event.java,v $
|
||||
* Revision 1.13 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.12 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.11 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.10 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.9 2005/02/20 13:05:32 justb
|
||||
* removed the Postlet (integrated in Pushlet protocol)
|
||||
*
|
||||
* Revision 1.8 2005/02/15 13:29:24 justb
|
||||
* add toQueryString()
|
||||
*
|
||||
* Revision 1.7 2005/01/18 16:47:10 justb
|
||||
* protocol changes for v2 and publishing from pushlet client
|
||||
*
|
||||
* Revision 1.6 2005/01/13 14:47:15 justb
|
||||
* control evt: send response on same (control) connection
|
||||
*
|
||||
* Revision 1.5 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.4 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the event data.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: Event.java,v 1.13 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
public class Event implements Protocol, Serializable {
|
||||
|
||||
protected Map attributes = new HashMap(3);
|
||||
|
||||
public Event(String anEventType) {
|
||||
this(anEventType, null);
|
||||
}
|
||||
|
||||
public Event(String anEventType, Map theAttributes) {
|
||||
|
||||
if (theAttributes != null) {
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
// Set required field event type
|
||||
setField(P_EVENT, anEventType);
|
||||
|
||||
// Set time in seconds since 1970
|
||||
setField(P_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public Event(Map theAttributes) {
|
||||
if (!theAttributes.containsKey(P_EVENT)) {
|
||||
throw new IllegalArgumentException(P_EVENT + " not found in attributes");
|
||||
}
|
||||
setAttrs(theAttributes);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject) {
|
||||
return createDataEvent(aSubject, null);
|
||||
}
|
||||
|
||||
public static Event createDataEvent(String aSubject, Map theAttributes) {
|
||||
Event dataEvent = new Event(E_DATA, theAttributes);
|
||||
dataEvent.setField(P_SUBJECT, aSubject);
|
||||
return dataEvent;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return getField(P_EVENT);
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return getField(P_SUBJECT);
|
||||
}
|
||||
|
||||
public void setField(String name, String value) {
|
||||
attributes.put(name, value);
|
||||
}
|
||||
|
||||
public void setField(String name, int value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public void setField(String name, long value) {
|
||||
attributes.put(name, value + "");
|
||||
}
|
||||
|
||||
public String getField(String name) {
|
||||
return (String) attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return field; if null return default.
|
||||
*/
|
||||
public String getField(String name, String aDefault) {
|
||||
String result = getField(name);
|
||||
return result == null ? aDefault : result;
|
||||
}
|
||||
|
||||
public Iterator getFieldNames() {
|
||||
return attributes.keySet().iterator();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return attributes.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to HTTP query string.
|
||||
*/
|
||||
public String toQueryString() {
|
||||
String queryString = "";
|
||||
String amp = "";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
queryString = queryString + amp + nextAttrName + "=" + nextAttrValue;
|
||||
// After first add "&".
|
||||
amp = "&";
|
||||
}
|
||||
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public String toXML(boolean strict) {
|
||||
String xmlString = "<event ";
|
||||
for (Iterator iter = getFieldNames(); iter.hasNext();) {
|
||||
String nextAttrName = (String) iter.next();
|
||||
String nextAttrValue = getField(nextAttrName);
|
||||
xmlString = xmlString + nextAttrName + "=\"" + (strict ? Sys.forHTMLTag(nextAttrValue) : nextAttrValue) + "\" ";
|
||||
}
|
||||
|
||||
xmlString += "/>";
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
return toXML(false);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
// Clone the Event by using copy constructor
|
||||
return new Event(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy given attributes into event attributes
|
||||
*/
|
||||
private void setAttrs(Map theAttributes) {
|
||||
attributes.putAll(theAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: Event.java,v $
|
||||
* Revision 1.13 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.12 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.11 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.10 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.9 2005/02/20 13:05:32 justb
|
||||
* removed the Postlet (integrated in Pushlet protocol)
|
||||
*
|
||||
* Revision 1.8 2005/02/15 13:29:24 justb
|
||||
* add toQueryString()
|
||||
*
|
||||
* Revision 1.7 2005/01/18 16:47:10 justb
|
||||
* protocol changes for v2 and publishing from pushlet client
|
||||
*
|
||||
* Revision 1.6 2005/01/13 14:47:15 justb
|
||||
* control evt: send response on same (control) connection
|
||||
*
|
||||
* Revision 1.5 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.4 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:30 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
*/
|
||||
|
||||
+185
-185
@@ -1,185 +1,185 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventPullSource.java,v 1.15 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* ABC for specifc EventPullSources.
|
||||
*/
|
||||
abstract public class EventPullSource implements EventSource, Runnable {
|
||||
private volatile boolean alive = false;
|
||||
private volatile boolean active = false;
|
||||
private static int threadNum = 0;
|
||||
private Thread thread;
|
||||
|
||||
public EventPullSource() {
|
||||
}
|
||||
|
||||
abstract protected long getSleepTime();
|
||||
|
||||
abstract protected Event pullEvent();
|
||||
|
||||
public void start() {
|
||||
thread = new Thread(this, "EventPullSource-" + (++threadNum));
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the event generator thread.
|
||||
*/
|
||||
public void stop() {
|
||||
alive = false;
|
||||
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the event generator thread.
|
||||
*/
|
||||
synchronized public void activate() {
|
||||
if (active) {
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
if (!alive) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
Log.debug(getClass().getName() + ": notifying...");
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the event generator thread.
|
||||
*/
|
||||
public void passivate() {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main loop: sleep, generate event and publish.
|
||||
*/
|
||||
public void run() {
|
||||
Log.debug(getClass().getName() + ": starting...");
|
||||
alive = true;
|
||||
while (alive) {
|
||||
try {
|
||||
|
||||
Thread.sleep(getSleepTime());
|
||||
|
||||
// Stopped during sleep: end loop.
|
||||
if (!alive) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If passivated wait until we get
|
||||
// get notify()-ied. If there are no subscribers
|
||||
// it wasts CPU to remain producing events...
|
||||
synchronized (this) {
|
||||
while (!active) {
|
||||
Log.debug(getClass().getName() + ": waiting...");
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
// Derived class should produce an event.
|
||||
Event event = pullEvent();
|
||||
|
||||
// Let the publisher push it to subscribers.
|
||||
Dispatcher.getInstance().multicast(event);
|
||||
} catch (Throwable t) {
|
||||
Log.warn("EventPullSource exception while multicasting ", t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.debug(getClass().getName() + ": stopped");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventPullSource.java,v $
|
||||
* Revision 1.15 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.14 2005/02/28 09:14:55 justb
|
||||
* sessmgr/dispatcher factory/singleton support
|
||||
*
|
||||
* Revision 1.13 2005/02/21 16:59:08 justb
|
||||
* SessionManager and session lease introduced
|
||||
*
|
||||
* Revision 1.12 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/18 09:54:15 justb
|
||||
* refactor: rename Publisher Dispatcher and single Subscriber class
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventPullSource.java,v 1.15 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* ABC for specifc EventPullSources.
|
||||
*/
|
||||
abstract public class EventPullSource implements EventSource, Runnable {
|
||||
private volatile boolean alive = false;
|
||||
private volatile boolean active = false;
|
||||
private static int threadNum = 0;
|
||||
private Thread thread;
|
||||
|
||||
public EventPullSource() {
|
||||
}
|
||||
|
||||
abstract protected long getSleepTime();
|
||||
|
||||
abstract protected Event pullEvent();
|
||||
|
||||
public void start() {
|
||||
thread = new Thread(this, "EventPullSource-" + (++threadNum));
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the event generator thread.
|
||||
*/
|
||||
public void stop() {
|
||||
alive = false;
|
||||
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the event generator thread.
|
||||
*/
|
||||
synchronized public void activate() {
|
||||
if (active) {
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
if (!alive) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
Log.debug(getClass().getName() + ": notifying...");
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the event generator thread.
|
||||
*/
|
||||
public void passivate() {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main loop: sleep, generate event and publish.
|
||||
*/
|
||||
public void run() {
|
||||
Log.debug(getClass().getName() + ": starting...");
|
||||
alive = true;
|
||||
while (alive) {
|
||||
try {
|
||||
|
||||
Thread.sleep(getSleepTime());
|
||||
|
||||
// Stopped during sleep: end loop.
|
||||
if (!alive) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If passivated wait until we get
|
||||
// get notify()-ied. If there are no subscribers
|
||||
// it wasts CPU to remain producing events...
|
||||
synchronized (this) {
|
||||
while (!active) {
|
||||
Log.debug(getClass().getName() + ": waiting...");
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
// Derived class should produce an event.
|
||||
Event event = pullEvent();
|
||||
|
||||
// Let the publisher push it to subscribers.
|
||||
Dispatcher.getInstance().multicast(event);
|
||||
} catch (Throwable t) {
|
||||
Log.warn("EventPullSource exception while multicasting ", t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.debug(getClass().getName() + ": stopped");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventPullSource.java,v $
|
||||
* Revision 1.15 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.14 2005/02/28 09:14:55 justb
|
||||
* sessmgr/dispatcher factory/singleton support
|
||||
*
|
||||
* Revision 1.13 2005/02/21 16:59:08 justb
|
||||
* SessionManager and session lease introduced
|
||||
*
|
||||
* Revision 1.12 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/18 09:54:15 justb
|
||||
* refactor: rename Publisher Dispatcher and single Subscriber class
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:05 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+269
-269
File diff suppressed because it is too large
Load Diff
+70
-70
@@ -1,70 +1,70 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventSource.java,v 1.7 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface for specifc Event(Pull/Push)Sources.
|
||||
*/
|
||||
public interface EventSource {
|
||||
/**
|
||||
* Activate the event source.
|
||||
*/
|
||||
public void activate();
|
||||
|
||||
/**
|
||||
* Deactivate the event source.
|
||||
*/
|
||||
public void passivate();
|
||||
|
||||
/**
|
||||
* Halt the event source.
|
||||
*/
|
||||
public void stop();
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSource.java,v $
|
||||
* Revision 1.7 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
/**
|
||||
* Abstract Event source from which Events are pulled.
|
||||
*
|
||||
* @version $Id: EventSource.java,v 1.7 2007/11/23 14:33:07 justb Exp $
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface for specifc Event(Pull/Push)Sources.
|
||||
*/
|
||||
public interface EventSource {
|
||||
/**
|
||||
* Activate the event source.
|
||||
*/
|
||||
public void activate();
|
||||
|
||||
/**
|
||||
* Deactivate the event source.
|
||||
*/
|
||||
public void passivate();
|
||||
|
||||
/**
|
||||
* Halt the event source.
|
||||
*/
|
||||
public void stop();
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSource.java,v $
|
||||
* Revision 1.7 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.6 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.5 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.3 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+169
-169
@@ -1,169 +1,169 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Maintains lifecycle of event sources.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: EventSourceManager.java,v 1.14 2007/11/10 13:44:02 justb Exp $
|
||||
*/
|
||||
public class EventSourceManager {
|
||||
private static Vector eventSources = new Vector(0);
|
||||
private static final String PROPERTIES_FILE = "sources.properties";
|
||||
|
||||
/**
|
||||
* Initialize event sources from properties file.
|
||||
*/
|
||||
public static void start(String aDirPath) {
|
||||
// Load Event sources using properties file.
|
||||
Log.info("EventSourceManager: start");
|
||||
|
||||
Properties properties = null;
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesResource(PROPERTIES_FILE);
|
||||
} catch (Throwable t) {
|
||||
// Try from provided dir (e.g. WEB_INF/pushlet.properties)
|
||||
String filePath = aDirPath + File.separator + PROPERTIES_FILE;
|
||||
Log.info("EventSourceManager: cannot load " + PROPERTIES_FILE + " from classpath, will try from " + filePath);
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesFile(filePath);
|
||||
} catch (Throwable t2) {
|
||||
Log.fatal("EventSourceManager: cannot load properties file from " + filePath, t);
|
||||
|
||||
// Give up
|
||||
Log.warn("EventSourceManager: not starting local event sources (maybe that is what you want)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create event source collection
|
||||
eventSources = new Vector(properties.size());
|
||||
|
||||
// Add the configured sources
|
||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
||||
String nextKey = (String) e.nextElement();
|
||||
String nextClass = properties.getProperty(nextKey);
|
||||
EventSource nextEventSource = null;
|
||||
try {
|
||||
nextEventSource = (EventSource) Class.forName(nextClass).newInstance();
|
||||
Log.info("created EventSource: key=" + nextKey + " class=" + nextClass);
|
||||
eventSources.addElement(nextEventSource);
|
||||
} catch (Exception ex) {
|
||||
Log.warn("Cannot create EventSource: class=" + nextClass, ex);
|
||||
}
|
||||
}
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all event sources.
|
||||
*/
|
||||
public static void activate() {
|
||||
Log.info("Activating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).activate();
|
||||
}
|
||||
Log.info("EventSources activated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all event sources.
|
||||
*/
|
||||
public static void passivate() {
|
||||
Log.info("Passivating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).passivate();
|
||||
}
|
||||
Log.info("EventSources passivated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Halt event sources.
|
||||
*/
|
||||
public static void stop() {
|
||||
Log.info("Stopping " + eventSources.size() + " EventSources...");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).stop();
|
||||
}
|
||||
Log.info("EventSources stopped");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSourceManager.java,v $
|
||||
* Revision 1.14 2007/11/10 13:44:02 justb
|
||||
* pushlet.properties and sources.properties can now also be put under WEB-INF
|
||||
*
|
||||
* Revision 1.13 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.12 2005/02/18 12:36:47 justb
|
||||
* changes for renaming and configurability
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/15 13:29:49 justb
|
||||
* use Sys.loadPropertiesResource()
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/08/12 13:18:54 justb
|
||||
* cosmetic changes
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:41:35 justb
|
||||
* replace static initalizer with explicit init()
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/31 08:26:54 just
|
||||
* Changed classloader that loads eventsources.properties to use EventSourceManager's classloader
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
import nl.justobjects.pushlet.util.Sys;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Maintains lifecycle of event sources.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: EventSourceManager.java,v 1.14 2007/11/10 13:44:02 justb Exp $
|
||||
*/
|
||||
public class EventSourceManager {
|
||||
private static Vector eventSources = new Vector(0);
|
||||
private static final String PROPERTIES_FILE = "sources.properties";
|
||||
|
||||
/**
|
||||
* Initialize event sources from properties file.
|
||||
*/
|
||||
public static void start(String aDirPath) {
|
||||
// Load Event sources using properties file.
|
||||
Log.info("EventSourceManager: start");
|
||||
|
||||
Properties properties = null;
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesResource(PROPERTIES_FILE);
|
||||
} catch (Throwable t) {
|
||||
// Try from provided dir (e.g. WEB_INF/pushlet.properties)
|
||||
String filePath = aDirPath + File.separator + PROPERTIES_FILE;
|
||||
Log.info("EventSourceManager: cannot load " + PROPERTIES_FILE + " from classpath, will try from " + filePath);
|
||||
|
||||
try {
|
||||
properties = Sys.loadPropertiesFile(filePath);
|
||||
} catch (Throwable t2) {
|
||||
Log.fatal("EventSourceManager: cannot load properties file from " + filePath, t);
|
||||
|
||||
// Give up
|
||||
Log.warn("EventSourceManager: not starting local event sources (maybe that is what you want)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create event source collection
|
||||
eventSources = new Vector(properties.size());
|
||||
|
||||
// Add the configured sources
|
||||
for (Enumeration e = properties.keys(); e.hasMoreElements();) {
|
||||
String nextKey = (String) e.nextElement();
|
||||
String nextClass = properties.getProperty(nextKey);
|
||||
EventSource nextEventSource = null;
|
||||
try {
|
||||
nextEventSource = (EventSource) Class.forName(nextClass).newInstance();
|
||||
Log.info("created EventSource: key=" + nextKey + " class=" + nextClass);
|
||||
eventSources.addElement(nextEventSource);
|
||||
} catch (Exception ex) {
|
||||
Log.warn("Cannot create EventSource: class=" + nextClass, ex);
|
||||
}
|
||||
}
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all event sources.
|
||||
*/
|
||||
public static void activate() {
|
||||
Log.info("Activating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).activate();
|
||||
}
|
||||
Log.info("EventSources activated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate all event sources.
|
||||
*/
|
||||
public static void passivate() {
|
||||
Log.info("Passivating " + eventSources.size() + " EventSources");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).passivate();
|
||||
}
|
||||
Log.info("EventSources passivated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Halt event sources.
|
||||
*/
|
||||
public static void stop() {
|
||||
Log.info("Stopping " + eventSources.size() + " EventSources...");
|
||||
for (int i = 0; i < eventSources.size(); i++) {
|
||||
((EventSource) eventSources.elementAt(i)).stop();
|
||||
}
|
||||
Log.info("EventSources stopped");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: EventSourceManager.java,v $
|
||||
* Revision 1.14 2007/11/10 13:44:02 justb
|
||||
* pushlet.properties and sources.properties can now also be put under WEB-INF
|
||||
*
|
||||
* Revision 1.13 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.12 2005/02/18 12:36:47 justb
|
||||
* changes for renaming and configurability
|
||||
*
|
||||
* Revision 1.11 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.10 2005/02/15 13:29:49 justb
|
||||
* use Sys.loadPropertiesResource()
|
||||
*
|
||||
* Revision 1.9 2004/09/20 22:01:38 justb
|
||||
* more changes for new protocol
|
||||
*
|
||||
* Revision 1.8 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.7 2004/08/15 16:00:15 justb
|
||||
* enhancements to pull mode
|
||||
*
|
||||
* Revision 1.6 2004/08/13 23:36:05 justb
|
||||
* rewrite of Pullet into Pushlet "pull" mode
|
||||
*
|
||||
* Revision 1.5 2004/08/12 13:18:54 justb
|
||||
* cosmetic changes
|
||||
*
|
||||
* Revision 1.4 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:41:35 justb
|
||||
* replace static initalizer with explicit init()
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:15:08 justb
|
||||
* support for XML encoded Events
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:17 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/10/30 14:15:47 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/31 08:26:54 just
|
||||
* Changed classloader that loads eventsources.properties to use EventSourceManager's classloader
|
||||
*
|
||||
* Revision 1.2 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+99
-99
@@ -1,99 +1,99 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* Implementation of ClientAdapter that sends Events as serialized objects.
|
||||
* <p/>
|
||||
* NOTE: You are discouraged to use this adapter, since it is Java-only
|
||||
* and may have JVM-specific problems. Far better choice is to use XML
|
||||
* and the XMLAdapter.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: SerializedAdapter.java,v 1.4 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
class SerializedAdapter implements ClientAdapter {
|
||||
private ObjectOutputStream out = null;
|
||||
public static final String CONTENT_TYPE = "application/x-java-serialized-object";
|
||||
private HttpServletResponse servletRsp;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public SerializedAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
servletRsp.setContentType(CONTENT_TYPE);
|
||||
|
||||
// Use a serialized object output stream
|
||||
out = new ObjectOutputStream(servletRsp.getOutputStream());
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
out.writeObject(anEvent);
|
||||
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
public void stop() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: SerializedAdapter.java,v $
|
||||
* Revision 1.4 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:13:48 justb
|
||||
* fixed blocking for java.net.URL with HTTP/1.1 (JVMs > 1.1)
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:18 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* Implementation of ClientAdapter that sends Events as serialized objects.
|
||||
* <p/>
|
||||
* NOTE: You are discouraged to use this adapter, since it is Java-only
|
||||
* and may have JVM-specific problems. Far better choice is to use XML
|
||||
* and the XMLAdapter.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: SerializedAdapter.java,v 1.4 2007/11/23 14:33:07 justb Exp $
|
||||
*/
|
||||
class SerializedAdapter implements ClientAdapter {
|
||||
private ObjectOutputStream out = null;
|
||||
public static final String CONTENT_TYPE = "application/x-java-serialized-object";
|
||||
private HttpServletResponse servletRsp;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public SerializedAdapter(HttpServletResponse aServletResponse) {
|
||||
servletRsp = aServletResponse;
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
servletRsp.setContentType(CONTENT_TYPE);
|
||||
|
||||
// Use a serialized object output stream
|
||||
out = new ObjectOutputStream(servletRsp.getOutputStream());
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push Event to client.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
out.writeObject(anEvent);
|
||||
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
public void stop() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: SerializedAdapter.java,v $
|
||||
* Revision 1.4 2007/11/23 14:33:07 justb
|
||||
* core classes now configurable through factory
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:46 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.4 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.3 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.2 2003/05/18 16:13:48 justb
|
||||
* fixed blocking for java.net.URL with HTTP/1.1 (JVMs > 1.1)
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/24 21:02:31 justb
|
||||
* import to sourceforge
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 22:48:18 justb
|
||||
* import to SF
|
||||
*
|
||||
* Revision 1.1.1.1 2002/09/20 14:19:03 justb
|
||||
* first import into SF
|
||||
*
|
||||
* Revision 1.5 2002/04/15 20:42:41 just
|
||||
* reformatting and renaming GuardedQueue to EventQueue
|
||||
*
|
||||
* Revision 1.4 2000/12/27 22:39:35 just
|
||||
* no message
|
||||
*
|
||||
* Revision 1.3 2000/08/21 20:48:29 just
|
||||
* added CVS log and id tags plus copyrights
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
+469
-469
File diff suppressed because it is too large
Load Diff
+137
-137
@@ -1,137 +1,137 @@
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* ClientAdapter that sends Events as XML.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: XMLAdapter.java,v 1.7 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
class XMLAdapter implements ClientAdapter {
|
||||
/**
|
||||
* Header for strict XML
|
||||
*/
|
||||
// public static final String XML_HEAD = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
|
||||
private String contentType = "text/plain;charset=UTF-8";
|
||||
private ServletOutputStream out = null;
|
||||
private HttpServletResponse servletRsp;
|
||||
private boolean strictXML;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse) {
|
||||
this(aServletResponse, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse, boolean useStrictXML) {
|
||||
servletRsp = aServletResponse;
|
||||
|
||||
// Strict XML implies returning a complete XML document
|
||||
strictXML = useStrictXML;
|
||||
if (strictXML) {
|
||||
contentType = "text/xml;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
// If content type is plain text
|
||||
// then this is not a complete XML document, but rather
|
||||
// a stream of XML documents where each document is
|
||||
// an Event. In strict XML mode a complete document is returned.
|
||||
servletRsp.setContentType(contentType);
|
||||
|
||||
out = servletRsp.getOutputStream();
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
|
||||
// Start XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("<pushlet>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force client to refresh the request.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
debug("event=" + anEvent);
|
||||
|
||||
// Send the event as XML to the client and flush.
|
||||
out.print(anEvent.toXML(strictXML));
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
public void stop() throws IOException {
|
||||
// Close XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("</pushlet>");
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void debug(String s) {
|
||||
Log.debug("[XMLAdapter]" + s);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: XMLAdapter.java,v $
|
||||
* Revision 1.7 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.6 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.5 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.4 2005/05/06 19:44:00 justb
|
||||
* added xml-strict format
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:47 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.5 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.4 2003/08/13 14:00:00 justb
|
||||
* some testing for applets; no real change
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:06 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/19 21:56:29 justb
|
||||
* various fixes for applet clients
|
||||
*
|
||||
* Revision 1.1 2003/05/18 16:12:28 justb
|
||||
* adding support for XML encoded Events
|
||||
*/
|
||||
// Copyright (c) 2000 Just Objects B.V. <just@justobjects.nl>
|
||||
// Distributable under LGPL license. See terms of license at gnu.org.
|
||||
|
||||
package nl.justobjects.pushlet.core;
|
||||
|
||||
import nl.justobjects.pushlet.util.Log;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* ClientAdapter that sends Events as XML.
|
||||
*
|
||||
* @author Just van den Broecke - Just Objects ©
|
||||
* @version $Id: XMLAdapter.java,v 1.7 2007/11/09 13:15:35 justb Exp $
|
||||
*/
|
||||
class XMLAdapter implements ClientAdapter {
|
||||
/**
|
||||
* Header for strict XML
|
||||
*/
|
||||
// public static final String XML_HEAD = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
|
||||
private String contentType = "text/plain;charset=UTF-8";
|
||||
private ServletOutputStream out = null;
|
||||
private HttpServletResponse servletRsp;
|
||||
private boolean strictXML;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse) {
|
||||
this(aServletResponse, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public XMLAdapter(HttpServletResponse aServletResponse, boolean useStrictXML) {
|
||||
servletRsp = aServletResponse;
|
||||
|
||||
// Strict XML implies returning a complete XML document
|
||||
strictXML = useStrictXML;
|
||||
if (strictXML) {
|
||||
contentType = "text/xml;charset=UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
|
||||
// If content type is plain text
|
||||
// then this is not a complete XML document, but rather
|
||||
// a stream of XML documents where each document is
|
||||
// an Event. In strict XML mode a complete document is returned.
|
||||
servletRsp.setContentType(contentType);
|
||||
|
||||
out = servletRsp.getOutputStream();
|
||||
|
||||
// Don't need this further
|
||||
servletRsp = null;
|
||||
|
||||
// Start XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("<pushlet>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force client to refresh the request.
|
||||
*/
|
||||
public void push(Event anEvent) throws IOException {
|
||||
debug("event=" + anEvent);
|
||||
|
||||
// Send the event as XML to the client and flush.
|
||||
out.print(anEvent.toXML(strictXML));
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
public void stop() throws IOException {
|
||||
// Close XML document if strict XML mode
|
||||
if (strictXML) {
|
||||
out.print("</pushlet>");
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void debug(String s) {
|
||||
Log.debug("[XMLAdapter]" + s);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: XMLAdapter.java,v $
|
||||
* Revision 1.7 2007/11/09 13:15:35 justb
|
||||
* add charset=UTF-8 in returned HTTP content types
|
||||
*
|
||||
* Revision 1.6 2006/05/15 11:52:53 justb
|
||||
* updates mainly for AJAX client
|
||||
*
|
||||
* Revision 1.5 2006/05/06 00:06:28 justb
|
||||
* first rough version AJAX client
|
||||
*
|
||||
* Revision 1.4 2005/05/06 19:44:00 justb
|
||||
* added xml-strict format
|
||||
*
|
||||
* Revision 1.3 2005/02/28 12:45:59 justb
|
||||
* introduced Command class
|
||||
*
|
||||
* Revision 1.2 2005/02/21 11:50:47 justb
|
||||
* ohase1 of refactoring Subscriber into Session/Controller/Subscriber
|
||||
*
|
||||
* Revision 1.1 2005/02/18 10:07:23 justb
|
||||
* many renamings of classes (make names compact)
|
||||
*
|
||||
* Revision 1.7 2004/09/03 22:35:37 justb
|
||||
* Almost complete rewrite, just checking in now
|
||||
*
|
||||
* Revision 1.6 2004/03/10 14:01:55 justb
|
||||
* formatting and *Subscriber refactoring
|
||||
*
|
||||
* Revision 1.5 2003/08/15 08:37:40 justb
|
||||
* fix/add Copyright+LGPL file headers and footers
|
||||
*
|
||||
* Revision 1.4 2003/08/13 14:00:00 justb
|
||||
* some testing for applets; no real change
|
||||
*
|
||||
* Revision 1.3 2003/08/12 09:57:06 justb
|
||||
* replaced all print statements to Log.*() calls
|
||||
*
|
||||
* Revision 1.2 2003/05/19 21:56:29 justb
|
||||
* various fixes for applet clients
|
||||
*
|
||||
* Revision 1.1 2003/05/18 16:12:28 justb
|
||||
* adding support for XML encoded Events
|
||||
*/
|
||||
|
||||
+293
-293
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user