mcconnell 02/03/07 21:55:07
Added: enterprise/time build.properties build.xml
enterprise/time/lib openorb_event-1.3.0.jar
enterprise/time/src/etc LICENSE.HTML LICENSE.TXT license.css
time.mf
enterprise/time/src/idl CosTime.idl CosTimerEvent.idl
TimeBase.idl
enterprise/time/src/java/org/apache/time DefaultTIO.java
DefaultTimeService.java
DefaultTimerEventHandler.java
DefaultTimerEventService.java DefaultUTO.java
ReleaseInfo.java TimeServer.java TimeServer.xinfo
TimeUtils.java package.html
enterprise/time/src/java/org/omg/CosTime package.html
enterprise/time/src/java/org/omg/CosTimerEvent package.html
enterprise/time/src/java/org/omg/TimeBase package.html
Log:
Initial commit.
Revision Changes Path
1.1 jakarta-avalon-apps/enterprise/time/build.properties
Index: build.properties
===================================================================
#
# The pss.properties file is read in by the build.xml file.
#
MAJOR=2
MINOR=0
MICRO=0
1.1 jakarta-avalon-apps/enterprise/time/build.xml
Index: build.xml
===================================================================
<!--
Time Service.
-->
<project name="time" default="help" basedir=".">
<property file="local.properties"/>
<property file="build.properties"/>
<target name="help" >
<echo>
Description
-----------
CORBA Time Service.
Main Targets:
-------------
all - cleans environment, builds distribution and examples
help - this message
Support Targets:
----------------
clean - destroy the build directory
build - invokes the general build target
dist - executes build, javadoc and support file creation
</echo>
</target>
<property name="VERSION" value="${MAJOR}.${MINOR}.${MICRO}"/>
<property name="enterprise" value=".." />
<property name="tools.path" value="${enterprise}/tools" />
<property name="tools.lib.path" value="${tools.path}/lib" />
<property name="orb.path" value="${enterprise}/orb" />
<property name="orb.lib.path" value="${orb.path}/lib" />
<property name="orb.dist.path" value="${orb.path}/dist" />
<property name="time.jar" value="time-${VERSION}.jar" />
<property name="src" value="src" />
<property name="idl" value="${src}/idl" />
<property name="etc" value="${src}/etc" />
<property name="build" value="build" />
<property name="dist" value="dist" />
<property name="lib" value="lib" />
<property name="overview.html" value="${etc}/overview.html" />
<property name="javadoc.root.path" value="${dist}/javadoc" />
<property name="avalon.href" value="http://jakarta.apache.org/avalon/api/"
/>
<property name="jdk.href" value="http://java.sun.com/j2se/1.4/docs/api/" />
<!-- the following properties must be updated locally using the
local.properties file -->
<property name="orb.href" value="../orb" />
<path id="project.classpath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
<fileset dir="${orb.lib.path}">
<include name="openorb*.jar" />
</fileset>
<fileset dir="${orb.dist.path}">
<include name="*.jar" />
</fileset>
<fileset dir="${tools.lib.path}">
<include name="*.jar" />
</fileset>
</path>
<!-- MAIN TARGETS -->
<target name="all" depends="clean,dist,javadoc"/>
<target name="build" depends="time"/>
<target name="dist" depends="build,support"/>
<target name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
<!-- PREPARE -->
<target name="prepare" >
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
</target>
<!-- ORB BLOCK/MANGER -->
<target name="time.context" depends="prepare" >
<mkdir dir="${build}/time" />
<mkdir dir="${build}/time/src" />
<mkdir dir="${build}/time/lib" />
</target>
<target name="build.context" depends="time.context">
<uptodate property="time.uptodate" targetfile="${dist}/${time.jar}">
<srcfiles dir="${src}/java">
<include name="**/*.*"/>
</srcfiles>
<srcfiles dir="${src}/idl">
<include name="**/*.*"/>
</srcfiles>
<srcfiles dir="${etc}">
<include name="*.*"/>
</srcfiles>
<srcfiles dir="${build}/time/src">
<include name="**/*.*"/>
</srcfiles>
</uptodate>
</target>
<target name="idl.context" >
<mkdir dir="${build}/time/src"/>
<uptodate property="idl.modified" targetfile="${idl}/CosTime.idl">
<srcfiles dir="${build}/time/src">
<include name="**/*"/>
</srcfiles>
</uptodate>
</target>
<target name="idl" depends="idl.context" if="idl.modified">
<echo message="Compiling IDL"/>
<mkdir dir="${build}/time"/>
<java failonerror="true" classname="org.openorb.compiler.IdlCompiler"
fork="true">
<classpath>
<path refid="project.classpath"/>
</classpath>
<arg line="-silence"/>
<arg line="-d ${build}/time/src"/>
<arg line="-I ${idl}"/>
<arg line="TimeBase.idl" />
</java>
<java failonerror="true" classname="org.openorb.compiler.IdlCompiler"
fork="true">
<classpath>
<path refid="project.classpath"/>
</classpath>
<arg line="-silence"/>
<arg line="-d ${build}/time/src"/>
<arg line="-I ${idl}"/>
<arg line="CosTime.idl" />
</java>
<java failonerror="true" classname="org.openorb.compiler.IdlCompiler"
fork="true">
<classpath>
<path refid="project.classpath"/>
</classpath>
<arg line="-silence"/>
<arg line="-d ${build}/time/src"/>
<arg line="-I ${idl}"/>
<arg line="CosTimerEvent.idl" />
</java>
</target>
<target name="time" depends="build.context,idl" unless="time.uptodate" >
<echo message="Building ORB Time Implementation."/>
<mkdir dir="${build}/time/lib"/>
<javac debug="off" destdir="${build}/time/lib" deprecation="true"
target="1.2">
<classpath>
<path refid="project.classpath" />
<pathelement path="${build}/time/lib" />
</classpath>
<src path="${build}/time/src" />
<src path="${src}/java" />
<include name="**"/>
</javac>
<copy todir="${build}/time/lib">
<fileset dir="${src}/java">
<include name="**/*.xinfo"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<jar jarfile="${dist}/${time.jar}" basedir="${build}/time/lib"
manifest="${etc}/time.mf" />
</target>
<!-- UTILITY TARGETS -->
<target name="support">
<copy todir="${dist}">
<fileset dir="${etc}">
<include name="README.TXT"/>
<include name="LICENSE.TXT"/>
</fileset>
</copy>
</target>
<target name="javadoc" depends="prepare" >
<mkdir dir="${javadoc.root.path}" />
<copy todir="${javadoc.root.path}/">
<fileset dir="${etc}">
<include name="LICENSE.HTML"/>
<include name="license.css"/>
</fileset>
</copy>
<javadoc destdir="${javadoc.root.path}"
doctitle="<h1>OMG Time Service 1.0</h1>"
noindex="false" author="false"
use="true"
overview="${overview.html}"
windowtitle="Apache Time Service"
bottom="<a href='[EMAIL PROTECTED]/LICENSE.HTML'/>License,
Disclaimer and due credits.</a>"
additionalparam="-breakiterator -J-Xmx128m"
packagenames="org.*"
>
<sourcepath path="${src}/java"/>
<sourcepath path="${build}/time/src"/>
<classpath>
<path refid="project.classpath" />
<pathelement path="${dist}/${time.jar}" />
</classpath>
<link href="${jdk.href}" />
<link href="${avalon.href}" />
<link href="${orb.href}" />
</javadoc>
</target>
</project>
1.1
jakarta-avalon-apps/enterprise/time/lib/openorb_event-1.3.0.jar
<<Binary file>>
1.1 jakarta-avalon-apps/enterprise/time/src/etc/LICENSE.HTML
Index: LICENSE.HTML
===================================================================
<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css" href="license.css" title="index">
<TITLE>Time Service License and Due Credits</TITLE>
<META name="description"
content="Apache Time Service Open Source License">
<META name="keywords" content="omg, time, apache, osm">
</HEAD>
<BODY BGCOLOR="#ffffff">
<p class="title">OMG Time Service <br>Disclaimers, Licenses and Due
Credits</p>
<hr>
<p class="sub-title">The Apache Software License, Version 1.1</p>
<pre class="pre">
Copyright (C) 1997-2001 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written permission.
For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
</pre>
</body>
</html>
1.1 jakarta-avalon-apps/enterprise/time/src/etc/LICENSE.TXT
Index: LICENSE.TXT
===================================================================
CORBA Enterprise Time Services
Disclaimers, Licenses and Due Credits
================================================================================
The Apache Software License, Version 1.1
================================================================================
Copyright (C) 1997-2001 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written permission.
For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
1.1 jakarta-avalon-apps/enterprise/time/src/etc/license.css
Index: license.css
===================================================================
A:link {color: blue}
A:visited {color: lightslategray}
A:active {color: blue}
H1 {
font-size: 12pt; color: black; font-style: normal; font-weight:
normal;
margin-left: 9px; margin-top: 20px; margin-bottom: 12px; font-family:
serif;
}
.logo {
position:absolute;
top:35px; left:0px;
}
.title {
font-size: 12pt; color: black;
margin-left: 9px; margin-top: 120px; margin-bottom: 12px;
}
.title2 {
font-size: 12pt; color: black;
margin-left: 9px; margin-top: 20px; margin-bottom: 12px;
}
.cover {
horizontal-align: center; text-align: center;
margin-left: 9px; margin-top: 3px; margin-bottom: 3px;
}
.sub-title {
font-size: 12pt; color: black;
margin-left: 9px; margin-top: 6px; margin-bottom: 12px;
}
.pre {
margin-left: 37px;
}
.map {
horizontal-align: center; text-align: center;
margin: 3px; margin-top: 48px;
}
.picture {
horizontal-align: center; text-align: center;
margin: 9px;
}
.figure {
horizontal-align: center; text-align: center; font-style: italic;
margin: 36px;
}
.icon {
vertical-align: bottom;
margin-left: 3px; margin-top: 24px; margin-right 24px;
}
.note {
vertical-align: bottom;
margin-left: 24px; margin-top: 3px; margin-right: 60px;
font-style: italic;
}
.menu {
vertical-align: bottom; font-size: 10pt; font-style: italic; color:
black;
margin-left: 9px; margin-top: 9px; margin-bottom: 6px;
}
.menu2 {
vertical-align: bottom; font-size: 10pt; font-style: italic; color:
black;
margin-left: 37px; margin-top: 3px; margin-bottom: 3px;
}
.item {
vertical-align: bottom; font-size: 10pt; font-style: italic; color:
black;
margin-left: 9px; margin-top: 9px; margin-bottom: 6px;
}
.body {
margin-left: 9px; font-size: 12pt;
}
.legal {
vertical-align: bottom; font-size: 10pt; color: black;
margin-left: 9px;
}
1.1 jakarta-avalon-apps/enterprise/time/src/etc/time.mf
Index: time.mf
===================================================================
Manifest-Version: 1.0
Class-Path: openorb-1.3.0.jar
Extension-Name: OMG Time Service
Specification-Vendor: Apache
Specification-Title: OMG Time Service
Specification-Version: 1.0
Implementation-Vendor-Id: APACHE
Implementation-Vendor: Apache Foundation
Implementation-Version: 1.0
Name: org/apache/time/TimeServer.class
Avalon-Block: true
1.1 jakarta-avalon-apps/enterprise/time/src/idl/CosTime.idl
Index: CosTime.idl
===================================================================
//File: CosTime.idl
#ifndef _COS_TIME_IDL_
#define _COS_TIME_IDL_
#include <TimeBase.idl>
#pragma prefix "omg.org"
module CosTime {
enum TimeComparison {
TCEqualTo,
TCLessThan,
TCGreaterThan,
TCIndeterminate
};
enum ComparisonType{
IntervalC,
MidC
};
enum OverlapType {
OTContainer,
OTContained,
OTOverlap,
OTNoOverlap
};
/**
* This exception is raised when the underlying trusted time service fails,
or is
* unable to provide time that meets the required security assurance.
*/
exception TimeUnavailable {};
interface TIO; // forward declaration
/**
* The UTO interface corresponds to an object that contains utc time, and is
the means for
* manipulating the time contained in the object. This interface has
operations for getting
* a UtcT type data structure containing the current value of time in the
object, as well as
* operations for getting the values of individual fields of utc time, getting
absolute time
* from relative time, and comparing and doing bounds operations on UTOs. The
UTO
* interface does not provide any operation for modifying the time in the
object. It is
* intended that UTOs are immutable.
*/
interface UTO {
/**
* This is the time attribute of a UTO represented as a value of type TimeT.
*/
readonly attribute TimeBase::TimeT time;
/**
* This is the inaccuracy attribute of a UTO represented as a value of type
InaccuracyT.
*/
readonly attribute TimeBase::InaccuracyT inaccuracy;
/**
* This is the time displacement factor attribute tdf of a UTO represented as
a value
* of type TdfT.
*/
readonly attribute TimeBase::TdfT tdf;
/**
* This attribute returns a properly populated UtcT structure with data
corresponding to
* the contents of the UTO.
*/
readonly attribute TimeBase::UtcT utc_time;
/**
* This attribute returns a UTO containing the absolute time
* corresponding to the relative time in object. Absolute
* time = current time + time in the object. Raises
* <CODE>CORBA::DATA_CONVERSION</CODE> exception if the
* attempt to obtain absolute time causes an overflow.
*/
UTO absolute_time();
/**
* Compares the time contained in the object with the time given in the input
parameter
* uto using the comparison type specified in the in parameter
comparison_type, and
* returns the result. See the description of TimeComparison in Section
14.2.2, Data
* Types, for an explanation of the result. See the explanation of
ComparisonType in
* Section 14.2.2 for an explanation of comparison types. Note that the time
in the object
* is always used as the first parameter in the comparison. The time in the
utc parameter
* is used as the second parameter in the comparison.
*/
TimeComparison compare_time(
in ComparisonType comparison_type,
in UTO a_uto
);
/**
* Returns a TIO representing the time interval between the time in the
object and the
* time in the UTO passed in the parameter uto. The interval returned is the
interval
* between the midpoints of the two UTOs and the inaccuracies in the UTOs are
not
* taken into consideration. The result is meaningless if the time base used
by the two
* UTOs are different.
*/
TIO time_to_interval( in UTO a_uto);
TIO interval();
};
/**
* The TIO represents a time interval and contains operations relevant to
time intervals.
*/
interface TIO {
/**
* This attribute returns an IntervalT structure with the values of its
fields filled
* in with the corresponding values from the TIO.
*/
readonly attribute TimeBase::IntervalT time_interval;
/**
* This operation returns a value of type OverlapType depending on how the
interval in
* the object and the time range represented by the parameter UTO overlap.
See the
* definition of OverlapType in Section 14.2.2, Data Types. The interval in
the object is
* interval A and the interval in the parameter UTO is interval B. If
OverlapType is not
* OTNoOverlap, then the out parameter overlap contains the overlap interval,
otherwise
* the out parameter contains the gap between the two intervals. The exception
* CORBA::BAD_PARAM is raised if the UTO passed in is invalid.
*/
OverlapType spans (
in UTO time,
out TIO overlap);
/**
* This operation returns a value of type OverlapType depending on how the
interval in
* the object and interval in the parameter TIO overlap. See the definition of
* OverlapType in Section 14.2.2, Data Types. The interval in the object is
interval A and
* the interval in the parameter TIO is interval B. If OverlapType is not
OTNoOverlap,
* then the out parameter overlap contains the overlap interval, otherwise
the out
* parameter contains the gap between the two intervals. The exception
* CORBA::BAD_PARAM is raised if the TIO passed in is invalid.
*/
OverlapType overlaps (
in TIO interval,
out TIO overlap);
/**
* Returns a UTO in which the inaccuracy interval is equal to the time
interval in the ITO
* and time value is the midpoint of the interval.
*/
UTO time ();
};
/**
* The TimeService interface provides operations for obtaining the current
time,
* constructing a UTO with specified values for each attribute, and
constructing a TIO
* with specified upper and lower bounds.
*/
interface TimeService {
/**
* The universal_time operation returns the current time and an estimate of
inaccuracy in
* a UTO. It raises TimeUnavailable exceptions to indicate failure of an
underlying time
* provider. The time returned in the UTO by this operation is not guaranteed
to be secure
* or trusted. If any time is available at all, that time is returned by this
operation.
*/
UTO universal_time()
raises(TimeUnavailable);
/**
* The secure_universal_time operation returns the current time in a UTO only
if the
* time can be guaranteed to have been obtained securely. In order to make
such a
* guarantee, the underlying Time Service must meet the criteria to be
followed for
* secure time, presented in Appendix A, Implementation Guidelines. If there
is any
* uncertainty at all about meeting any aspect of these criteria, then this
operation must
* return the TimeUnavailable exception. Thus, time obtained through this
operation can
* always be trusted.
*/
UTO secure_universal_time()
raises(TimeUnavailable);
/**
* The new_universal_time operation is used for constructing a new UTO. The
* parameters passed in are the time of type TimeT and inaccuracy of type
InaccuracyT.
* This is the only way to create a UTO with an arbitrary time from its
components. This
* is expected to be used for building UTOs that can be passed as the various
time
* arguments to the Timer Event Service, for example. CORBA::BAD_PARAM is
* raised in the case of an out-of-range parameter value for inaccuracy.
*/
UTO new_universal_time(
in TimeBase::TimeT time,
in TimeBase::InaccuracyT inaccuracy,
in TimeBase::TdfT tdf);
/**
* The uto_from_utc operation is used to create a UTO given a time in the
UtcT form.
* This has a single in parameter UTC, which contains a time together with
inaccuracy
* and tdf. The UTO returned is initialized with the values from the UTC
parameter. This
* operation is used to convert a UTC received over the wire into a UTO.
*/
UTO uto_from_utc(
in TimeBase::UtcT utc);
/**
* The new_interval operation is used to construct a new TIO. The parameters
are lower
* and upper, both of type TimeT, holding the lower and upper bounds of the
interval. If
* the value of the lower parameter is greater than the value of the upper
parameter, then
* a CORBA::BAD_PARAM exception is raised.
*/
TIO new_interval(
in TimeBase::TimeT lower,
in TimeBase::TimeT upper);
};
};
#endif /* ifndef _COS_TIME_IDL_ */
1.1
jakarta-avalon-apps/enterprise/time/src/idl/CosTimerEvent.idl
Index: CosTimerEvent.idl
===================================================================
//File: CosTimerEvent.idl
//Part of the Time Service
#ifndef _COS_TIMER_EVENT_IDL_
#define _COS_TIMER_EVENT_IDL_
#include <CosTime.idl>
#include <CosEventComm.idl>
module CosTimerEvent{
typePrefix CosTimerEvent "omg.org";
enum TimeType {
TTAbsolute,
TTRelative,
TTPeriodic
};
enum EventStatus {
ESTimeSet,
ESTimeCleared,
ESTriggered,
ESFailedTrigger
};
struct TimerEventT {
TimeBase::UtcT utc;
any event_data;
};
interface TimerEventHandler {
readonly attribute EventStatus status;
boolean time_set(
out CosTime::UTO uto);
void SetTimer(
in TimeType time_type,
in CosTime::UTO trigger_time);
boolean cancel_timer();
void set_data( in any event_data);
};
interface TimerEventService {
TimerEventHandler register(
in CosEventComm::PushConsumer event_interface,
in any data);
void unregister( in TimerEventHandler
timer_event_handler );
CosTime::UTO event_time( in TimerEventT
timer_event );
};
};
#endif // _COS_TIMER_EVENT_IDL_
1.1 jakarta-avalon-apps/enterprise/time/src/idl/TimeBase.idl
Index: TimeBase.idl
===================================================================
//File: TimeBase.idl
#ifndef _TIME_BASE_IDL_
#define _TIME_BASE_IDL_
#pragma prefix "omg.org"
/**
* All data structures pertaining to the basic Time Service, Universal Time
Object, and
* Time Interval Object are defined in the TimeBase module so that other
services can
* make use of these data structures without requiring the interface
definitions. The
* interface definitions and associated enums and exceptions are encapsulated
in the
* CosTime module.<p>
* The Time Service object manages Universal Time Objects (UTOs) and Time
Interval
* Objects (TIOs). It does so by providing methods for creating UTOs and TIOs.
* Each UTO represents a time, and each TIO represents a time interval, and
reference
* to each can be freely passed around, subject to certain caviats.<p>
* A number of types and interfaces are defined and used by this service. All
definitions
* of data structures are placed in the TimeBase module. All interfaces, and
associated
* enum and exception declarations are placed in the CosTime module. This
separation of
* basic data type definitions from interface related definitions allows other
services to
* use the time data types without explicitly incorporating the interfaces,
while allowing
* clients of those services to use the interfaces provided by the Time
Service to
* manipulate the data used by those services.
*/
module TimeBase {
/**
* TimeT represents a single time value, which is 64 bits in size, and
holds the number
* of 100 nanoseconds that have passed since the base time. For absolute
time the base is
* 15 October 1582 00:00.of the Gregorian Calendar. All absolute time
shall be computed
* using dates from the Gregorian Calendar.
*/
typedef unsigned long long TimeT;
/**
* InaccuracyT represents the value of inaccuracy in time in units of 100
* nanoseconds. As per the definition of the inaccuracy field in the
X/Open DCE Time
* Service [1], 48 bits is sufficient to hold this value.
*/
typedef TimeT InaccuracyT;
/**
* TdfT is of size 16 bits short type and holds the time displacement
factor in the form
* of minutes of displacement from the Greenwich Meridian. Displacements
East of the
* meridian are positive, while those to the West are negative.
*/
typedef short TdfT;
/**
* UtcT defines the structure of the time value that is used universally
in this service.
* The basic value of time is of type TimeT that is held in the time
field. Whether a
* UtcT structure is holding a relative or absolute time is determined
by its history.
* There is no explicit flag within the object holding that state
information. The iacclo
* and inacchi fields together hold a 48-bit estimate of inaccuracy in
the time field.
* These two fields together hold a value of type InaccuracyT packed
into 48 bits.
* The tdf field holds time zone information. Implementation must place
the time
* displacement factor for the local time zone in this field whenever
they create a UTO.
* <p>
* The contents of this structure are intended to be opaque, but in
order to be able to
* marshal it correctly, at least the types of fields need to be
identified.
*/
struct UtcT {
TimeT time; // 8 octets
unsigned long inacclo; // 4 octets
unsigned short inacchi; // 2 octets
TdfT tdf; // 2 octets
// total 16 octets.
};
/**
* This type holds a time interval represented as two TimeT values
corresponding to the
* lower and upper bound of the interval. An IntervalT structure
containing a lower
* bound greater than the upper bound is invalid. For the interval to be
meaningful, the
* time base used for the lower and upper bound must be the same, and
the time base
* itself must not be spanned by the interval.
*/
struct IntervalT {
TimeT lower_bound;
TimeT upper_bound;
};
};
#endif /* _TIME_BASE_IDL_ */
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/DefaultTIO.java
Index: DefaultTIO.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import org.omg.CORBA.ORB;
import org.omg.CosTime.*;
import org.omg.TimeBase.IntervalT;
/**
* Implementation of a Time Interval Object.
*/
public class DefaultTIO extends TIOPOA
{
ORB m_orb;
IntervalT m_interval;
public DefaultTIO(ORB orb)
{
m_orb = orb;
}
public DefaultTIO(ORB orb, IntervalT intervalt)
{
m_orb = orb;
m_interval = intervalt;
}
public DefaultTIO(ORB orb, long l, long l1)
{
m_orb = orb;
m_interval = new IntervalT(l, l1);
}
public IntervalT time_interval()
{
return m_interval;
}
public OverlapType spans(UTO uto, TIOHolder tioholder)
{
long l = uto.time();
long l1 = uto.inaccuracy();
if(l - l1 > m_interval.lower_bound && l + l1 < m_interval.upper_bound)
{
tioholder.value = uto.interval();
return OverlapType.OTContainer;
}
if(l - l1 < m_interval.lower_bound && l + l1 > m_interval.upper_bound)
{
tioholder.value = _this(m_orb);
return OverlapType.OTContained;
}
if(l - l1 > m_interval.lower_bound && l - l1 < m_interval.upper_bound)
{
long l2 = l - l1;
long l4 = m_interval.upper_bound;
DefaultTIO tioimpl1 = new DefaultTIO(m_orb, l2, l4);
tioholder.value = tioimpl1._this(m_orb);
return OverlapType.OTOverlap;
}
if(l + l1 > m_interval.lower_bound && l + l1 < m_interval.upper_bound)
{
long l3 = m_interval.lower_bound;
long l5 = l + l1;
DefaultTIO tioimpl2 = new DefaultTIO(m_orb, l3, l5);
tioholder.value = tioimpl2._this(m_orb);
return OverlapType.OTOverlap;
} else
{
DefaultTIO tioimpl = new DefaultTIO(m_orb);
tioholder.value = tioimpl._this(m_orb);
return OverlapType.OTNoOverlap;
}
}
public OverlapType overlaps(TIO tio, TIOHolder tioholder)
{
long l = tio.time_interval().lower_bound
+ (tio.time_interval().upper_bound -
tio.time_interval().lower_bound) / 2L;
long l1 = (tio.time_interval().upper_bound -
tio.time_interval().lower_bound) / 2L;
if(l - l1 > m_interval.lower_bound && l + l1 < m_interval.upper_bound)
{
tioholder.value = tio;
return OverlapType.OTContainer;
}
if(l - l1 < m_interval.lower_bound && l + l1 > m_interval.upper_bound)
{
tioholder.value = _this(m_orb);
return OverlapType.OTContained;
}
if(l - l1 > m_interval.lower_bound && l - l1 < m_interval.upper_bound)
{
long l2 = l - l1;
long l4 = m_interval.upper_bound;
DefaultTIO tioimpl1 = new DefaultTIO(m_orb, l2, l4);
tioholder.value = tioimpl1._this(m_orb);
return OverlapType.OTOverlap;
}
if(l + l1 > m_interval.lower_bound && l + l1 < m_interval.upper_bound)
{
long l3 = m_interval.lower_bound;
long l5 = l + l1;
DefaultTIO tioimpl2 = new DefaultTIO(m_orb, l3, l5);
tioholder.value = tioimpl2._this(m_orb);
return OverlapType.OTOverlap;
} else
{
DefaultTIO tioimpl = new DefaultTIO(m_orb);
tioholder.value = tioimpl._this(m_orb);
return OverlapType.OTNoOverlap;
}
}
public UTO time()
{
DefaultUTO uto = new DefaultUTO( m_orb,
(m_interval.upper_bound - m_interval.lower_bound) +
m_interval.lower_bound,
m_interval.upper_bound - m_interval.lower_bound,
(short)0 );
return uto._this();
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/DefaultTimeService.java
Index: DefaultTimeService.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import java.util.Date;
import org.omg.CORBA.ORB;
import org.omg.CosTime.*;
import org.omg.TimeBase.UtcT;
/**
* Default implementation of the time service.
*/
public class DefaultTimeService extends TimeServicePOA
{
private ORB m_orb;
private static long STDACCURACCY;
public DefaultTimeService(ORB orb, long value)
{
m_orb = orb;
STDACCURACCY = value;
}
public UTO universal_time()
throws TimeUnavailable
{
Date date = new Date();
DefaultUTO uto = new DefaultUTO(m_orb, date.getTime(), STDACCURACCY,
(short)0);
return uto._this(m_orb);
}
public UTO secure_universal_time()
throws TimeUnavailable
{
Date date = new Date();
DefaultUTO uto = new DefaultUTO(m_orb, date.getTime(), STDACCURACCY,
(short)0);
return uto._this(m_orb);
}
public UTO new_universal_time(long l, long l1, short word0)
{
DefaultUTO uto = new DefaultUTO(m_orb, l, l1, word0);
return uto._this(m_orb);
}
public UTO uto_from_utc(UtcT utct)
{
long l = (utct.inacchi << 4) + utct.inacclo;
DefaultUTO uto = new DefaultUTO(m_orb, utct.time, l, utct.tdf);
return uto._this(m_orb);
}
public TIO new_interval(long l, long l1)
{
DefaultTIO tio = new DefaultTIO(m_orb, l, l1);
return tio._this(m_orb);
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/DefaultTimerEventHandler.java
Index: DefaultTimerEventHandler.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import java.util.Date;
import org.omg.CORBA.*;
import org.omg.CosEventComm.Disconnected;
import org.omg.CosEventComm.PushConsumer;
import org.omg.CosTime.UTO;
import org.omg.CosTime.UTOHolder;
import org.omg.CosTimerEvent.*;
import org.omg.TimeBase.UtcT;
/**
* Default implementation of the timer event handler.
*/
public class DefaultTimerEventHandler extends TimerEventHandlerPOA
implements Runnable
{
ORB m_orb;
DefaultTimerEventService m_parent;
PushConsumer m_event_channel;
EventStatus m_status;
Any m_data;
boolean m_is_set;
boolean m_periodic;
long m_delay;
long m_last_relative;
long m_current_time;
long m_set_time;
Thread m_thread;
public DefaultTimerEventHandler(DefaultTimerEventService service, ORB
orb, PushConsumer cosumer, long value)
{
m_status = null;
m_data = null;
m_is_set = false;
m_periodic = false;
m_last_relative = 0L;
m_thread = null;
m_parent = service;
m_orb = orb;
m_event_channel = cosumer;
m_status = EventStatus.ESTimeCleared;
m_current_time = value;
}
public EventStatus status()
{
return m_status;
}
public boolean time_set(UTOHolder utoholder)
{
return m_is_set && m_status.value() == 0;
}
public void SetTimer(TimeType timetype, UTO uto)
{
m_thread = null;
m_set_time = (new Date()).getTime();
if(timetype.value() == 0)
{
Date date = new Date();
m_delay = uto.time() - date.getTime();
} else
{
if(timetype.value() == 2)
m_periodic = true;
if(uto.time() == 0L)
{
if(m_last_relative == 0L)
throw new BAD_PARAM();
m_delay = m_last_relative;
}
m_delay = uto.time();
m_last_relative = m_delay;
}
m_status = EventStatus.ESTimeSet;
m_thread = new Thread(this, "");
m_thread.start();
}
public boolean cancel_timer()
{
if(m_status.value() == 0 || m_status.value() == 2 && m_periodic)
{
m_status = EventStatus.ESTimeCleared;
m_thread = null;
return true;
} else
{
return false;
}
}
public void set_data(Any any)
{
m_data = m_orb.create_any();
m_data = any;
}
public void run()
{
TimerEventT timereventt = new TimerEventT(null, m_data);
Any any = m_orb.create_any();
while( true )
{
try
{
DefaultTimerEventHandler _tmp = this;
Thread.sleep(m_delay);
try
{
timereventt.utc = new UtcT((new Date()).getTime(), 0,
(short)0, (short)0);
TimerEventTHelper.insert(any, timereventt);
m_event_channel.push(any);
m_status = EventStatus.ESTriggered;
}
catch(Disconnected disconnected)
{
m_status = EventStatus.ESFailedTrigger;
}
catch(COMM_FAILURE comm_failure)
{
m_parent.unregister(_this());
break;
}
if(!m_periodic) break;
}
catch(InterruptedException interruptedexception) { }
}
m_thread = null;
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/DefaultTimerEventService.java
Index: DefaultTimerEventService.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import java.util.Date;
import java.util.Vector;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CosEventComm.PushConsumer;
import org.omg.CosTime.UTO;
import org.omg.CosTimerEvent.*;
/**
* Default implementation of the timer event service.
*/
public class DefaultTimerEventService extends TimerEventServicePOA
{
Vector m_vector;
ORB m_orb;
public DefaultTimerEventService(ORB orb)
{
m_orb = orb;
m_vector = new Vector();
}
public TimerEventHandler register(PushConsumer consumer, Any any)
{
DefaultTimerEventHandler timereventhandlerimpl = new
DefaultTimerEventHandler(
this, m_orb, consumer, (new Date()).getTime());
timereventhandlerimpl.set_data(any);
m_vector.addElement(timereventhandlerimpl);
return timereventhandlerimpl._this( m_orb );
}
public void unregister(TimerEventHandler timereventhandler)
{
m_vector.removeElement(timereventhandler);
}
public UTO event_time(TimerEventT timereventt)
{
DefaultUTO uto = new DefaultUTO( m_orb, timereventt.utc);
return uto._this( m_orb );
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/DefaultUTO.java
Index: DefaultUTO.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import java.util.Date;
import org.omg.CORBA.ORB;
import org.omg.CosTime.*;
import org.omg.TimeBase.UtcT;
/**
* Implementation of a Universal Time Object.
*/
public class DefaultUTO extends UTOPOA
{
private long m_uto_time;
private long m_uto_inaccuracy;
private short m_uto_tdf;
private ORB m_orb;
public DefaultUTO(ORB orb)
{
m_orb = orb;
}
public DefaultUTO(ORB orb, UtcT utct)
{
m_orb = orb;
m_uto_time = utct.time;
m_uto_tdf = utct.tdf;
m_uto_inaccuracy = (utct.inacchi << 4) + utct.inacclo;
}
public DefaultUTO(ORB orb, long l, long l1, short word0)
{
m_orb = orb;
m_uto_time = l;
m_uto_inaccuracy = l1;
m_uto_tdf = word0;
}
public long time()
{
return m_uto_time;
}
public long inaccuracy()
{
return m_uto_inaccuracy;
}
public short tdf()
{
return m_uto_tdf;
}
public UtcT utc_time()
{
long l = m_uto_inaccuracy >> 32;
return new UtcT(m_uto_time, (int)(m_uto_inaccuracy & 0x7fffffffL),
(short)(int)(l & 32767L), m_uto_tdf);
}
public UTO absolute_time()
{
long l = (new Date()).getTime();
DefaultUTO DefaultUTO = new DefaultUTO(m_orb, l, 0L, (short)0);
return DefaultUTO._this(m_orb);
}
public TimeComparison compare_time(ComparisonType comparisontype, UTO uto)
{
if(comparisontype.value() == ComparisonType.IntervalC.value())
{
if(uto.time() == m_uto_time && uto.inaccuracy() == 0L &&
m_uto_inaccuracy == 0L)
return TimeComparison.TCEqualTo;
if(m_uto_time < uto.time() && m_uto_time + m_uto_inaccuracy >
uto.time() - uto.inaccuracy())
return TimeComparison.TCIndeterminate;
if(m_uto_time > uto.time() && m_uto_time - m_uto_inaccuracy <
uto.time() + uto.inaccuracy())
return TimeComparison.TCIndeterminate;
if(m_uto_time > uto.time())
return TimeComparison.TCGreaterThan;
if(m_uto_time < uto.time())
return TimeComparison.TCLessThan;
} else
if(comparisontype.value() == ComparisonType.MidC.value())
{
if(uto.time() == m_uto_time)
return TimeComparison.TCEqualTo;
if(uto.time() < m_uto_time)
return TimeComparison.TCGreaterThan;
if(uto.time() > m_uto_time)
return TimeComparison.TCLessThan;
}
return TimeComparison.TCLessThan;
}
public TIO time_to_interval(UTO uto)
{
long l;
long l1;
if(m_uto_time < uto.time())
{
l = m_uto_time;
l1 = uto.time();
} else
{
l1 = m_uto_time;
l = uto.time();
}
DefaultTIO tio = new DefaultTIO(m_orb, l, l1);
return tio._this(m_orb);
}
public TIO interval()
{
DefaultTIO tio = new DefaultTIO(m_orb, m_uto_time - m_uto_inaccuracy,
m_uto_time + m_uto_inaccuracy);
return tio._this(m_orb);
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/ReleaseInfo.java
Index: ReleaseInfo.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
/**
* Release information for the time service implementation.
*/
public class ReleaseInfo extends org.openorb.ReleaseInfo
{
public static final short OPENORB_TIME_MAJOR = 2;
public static final short OPENORB_TIME_MINOR = 0;
public static final short OPENORB_TIME_MINOR_CHANGE = 0;
public static final String OPENORB_TIME_VERSION = "2.0";
public static final String VERSION = "2.0 over ORB Version 1.3";
public static final String RELEASE = "TimeService Version 2.0 over ORB
Implementation Version 1.3.0";
public static String RELEASE_TAG =
"TimeService_2_0_0_over_ORB_Implementation_Version 1.3.0";
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/TimeServer.java
Index: TimeServer.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*
* Original contribution by OSM SARL, http://www.osm.net
*/
package org.apache.time;
import java.io.File;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Properties;
import org.omg.CORBA.ORB;
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.Policy;
import org.omg.CORBA.LocalObject;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.ImplicitActivationPolicyValue;
import org.omg.PortableServer.LifespanPolicyValue;
import org.omg.PortableServer.IdUniquenessPolicyValue;
import org.omg.CosTime.TimeServiceHelper;
import org.omg.CosTime.TimeService;
import org.apache.avalon.framework.CascadingException;
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.phoenix.BlockContext;
import org.apache.avalon.phoenix.Block;
import org.apache.orb.ORBFactoryService;
import org.apache.orb.util.IOR;
/**
* <code>TimeBlock</code> compliant with the OMG CosTime interface
specification.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
*/
public class TimeServer extends LocalObject
implements Block, LogEnabled, Configurable, Composable, Contextualizable,
Initializable, Startable, Disposable, TimeService
{
private Logger m_logger;
private static final String ROOT_POA = "RootPOA";
protected Configuration m_configuration;
protected ORB m_orb;
protected POA m_root;
private String m_ior;
private int m_inaccuracy = 10000;
private org.omg.CosTime.TimeService m_time;
private static Thread m_thread;
/**
* Application context
*/
BlockContext context;
/**
* ORB factory
*/
private ORBFactoryService m_factory;
//=======================================================================
// Loggable
//=======================================================================
public void enableLogging( final Logger logger )
{
m_logger = logger;
}
protected Logger getLogger()
{
return m_logger;
}
//=================================================================
// Contextualizable
//=================================================================
public void contextualize( Context context ) throws ContextException
{
if( getLogger().isDebugEnabled() ) getLogger().debug( "contextualize"
);
if( context instanceof BlockContext )
{
this.context = (BlockContext) context;
}
else
{
throw new ContextException("Supplied context does not implement
BlockContext.");
}
}
//=================================================================
// Composable
//=================================================================
/**
* Pass the <code>ComponentManager</code> to the <code>Composable</code>.
* The <code>Composable</code> implementation should use the specified
* <code>ComponentManager</code> to acquire the components it needs for
* execution.
*
* @param manager The <code>ComponentManager</code> which this
* <code>Composer</code> uses.
*/
public void compose( ComponentManager manager )
throws ComponentException
{
try
{
if( getLogger().isDebugEnabled() ) getLogger().debug( "compose" );
m_factory = ((ORBFactoryService) manager.lookup("ORB-FACTORY"));
}
catch( Exception e )
{
String error = "unexpected exception during composition";
if( getLogger().isErrorEnabled() ) getLogger().error( error, e
);
throw new ComponentException( error, e );
}
}
//=======================================================================
// Configurable
//=======================================================================
public void configure( final Configuration config )
throws ConfigurationException
{
m_configuration = config;
}
//=======================================================================
// Initializable
//=======================================================================
public void initialize()
throws Exception
{
//
// initialize configuration
//
if( getLogger().isDebugEnabled() ) getLogger().debug( "initialize" );
// ORB
try
{
if( getLogger().isDebugEnabled() ) getLogger().debug("creating
ORB" );
m_orb = m_factory.createORB( null, null,
getLogger().getChildLogger("orb"),
context, m_configuration.getChild("orb"));
}
catch( Throwable e)
{
throw new ConfigurationException( "Failed to establish ORB.", e);
}
try
{
m_inaccuracy =
m_configuration.getChild("profile").getAttributeAsInteger(
"inaccuracy", m_inaccuracy );
if( getLogger().isDebugEnabled() ) getLogger().debug("setting
inaccuracy to " + m_inaccuracy );
} catch (Exception e)
{
if( getLogger().isDebugEnabled() ) getLogger().debug("setting
inaccuracy to default " + m_inaccuracy );
}
try
{
m_ior = m_configuration.getAttribute( "ior" );
if( getLogger().isDebugEnabled() ) getLogger().debug("setting IOR
path to " + m_ior );
}
catch (Exception e)
{
if( getLogger().isDebugEnabled() ) getLogger().debug("IOR
publication disabled" );
}
//
// create the time server runtime POA
//
if( getLogger().isDebugEnabled() ) getLogger().debug("locating root
POA" );
try
{
m_root =
POAHelper.narrow(m_orb.resolve_initial_references(ROOT_POA));
}
catch ( InvalidName e )
{
throw new Exception("cannot locate 'RootPOA' initial service");
}
catch ( Throwable e )
{
throw new CascadingException("unexpected exception while
resolving root POA", e );
}
if( getLogger().isDebugEnabled() ) getLogger().debug("creating time
service POA" );
try
{
POA timePOA = m_root.create_POA
(
"TimeServicePOA", // adapter name
m_root.the_POAManager(), // manager
new Policy[]
{ // policy set
m_root.create_implicit_activation_policy(
ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION),
m_root.create_lifespan_policy( LifespanPolicyValue.PERSISTENT
),
m_root.create_id_uniqueness_policy(
IdUniquenessPolicyValue.UNIQUE_ID)
}
);
org.omg.CosTime.TimeServicePOA servant =
new org.apache.time.DefaultTimeService( m_orb, m_inaccuracy );
byte[] servantID = timePOA.activate_object(servant);
org.omg.CORBA.Object object = null;
object = timePOA.id_to_reference(servantID);
m_time = TimeServiceHelper.narrow( object );
if( getLogger().isDebugEnabled() ) getLogger().debug("POA
established" );
}
catch( Exception e)
{
throw new CascadingException("cannot instantiate POA", e);
}
String banner = "OSM Time Service.";
if( getLogger().isDebugEnabled() ) getLogger().info( banner );
}
//=======================================================================
// Startable
//=======================================================================
/**
* Start the TimeServer.
*/
public void start()
throws Exception
{
//
// set object reference
//
if( m_ior != null )
{
if( getLogger().isDebugEnabled() ) getLogger().debug("creating
external object reference" );
try
{
IOR.writeIOR( m_orb, m_time, m_ior );
if( getLogger().isDebugEnabled() ) getLogger().debug(
"published IOR to: " + m_ior );
}
catch (Exception e)
{
throw new CascadingException( "failed to create external IOR
on " + m_ior );
}
}
m_thread = new Thread(
new Runnable() {
public void run()
{
if( getLogger().isDebugEnabled() )
getLogger().debug("starting time server" );
try
{
m_root.the_POAManager().activate();
m_orb.run();
}
catch (Exception e)
{
throw new CascadingRuntimeException( "failed to activate
the POA", e );
}
}
}
);
m_thread.start();
}
/**
* Stops the component.
*/
public void stop()
throws Exception
{
m_orb.shutdown( false );
}
//=======================================================================
// Disposable
//=======================================================================
public void dispose()
{
if( getLogger().isDebugEnabled() ) getLogger().debug("dispose" );
}
//=======================================================================
// TimeService
//=======================================================================
/**
* The universal_time operation returns the current time and an estimate
of inaccuracy in
* a UTO. It raises TimeUnavailable exceptions to indicate failure of an
underlying time
* provider. The time returned in the UTO by this operation is not
guaranteed to be secure
* or trusted. If any time is available at all, that time is returned by
this operation.
*/
public org.omg.CosTime.UTO universal_time()
throws org.omg.CosTime.TimeUnavailable
{
return m_time.universal_time();
}
/**
* The secure_universal_time operation returns the current time in a UTO
only if the
* time can be guaranteed to have been obtained securely. In order to make
such a
* guarantee, the underlying Time Service must meet the criteria to be
followed for
* secure time, presented in Appendix A, Implementation Guidelines. If
there is any
* uncertainty at all about meeting any aspect of these criteria, then
this operation must
* return the TimeUnavailable exception. Thus, time obtained through this
operation can
* always be trusted.
*/
public org.omg.CosTime.UTO secure_universal_time()
throws org.omg.CosTime.TimeUnavailable
{
return m_time.secure_universal_time();
}
/**
* The new_universal_time operation is used for constructing a new UTO. The
* parameters passed in are the time of type TimeT and inaccuracy of type
InaccuracyT.
* This is the only way to create a UTO with an arbitrary time from its
components. This
* is expected to be used for building UTOs that can be passed as the
various time
* arguments to the Timer Event Service, for example. CORBA::BAD_PARAM is
* raised in the case of an out-of-range parameter value for inaccuracy.
*/
public org.omg.CosTime.UTO new_universal_time(long t, long inac, short
tdf)
{
return m_time.new_universal_time( t, inac, tdf );
}
/**
* The uto_from_utc operation is used to create a UTO given a time in the
UtcT form.
* This has a single in parameter UTC, which contains a time together with
inaccuracy
* and tdf. The UTO returned is initialized with the values from the UTC
parameter. This
* operation is used to convert a UTC received over the wire into a UTO.
*/
public org.omg.CosTime.UTO uto_from_utc(org.omg.TimeBase.UtcT utc)
{
return m_time.uto_from_utc( utc );
}
/**
* The new_interval operation is used to construct a new TIO. The
parameters are lower
* and upper, both of type TimeT, holding the lower and upper bounds of
the interval. If
* the value of the lower parameter is greater than the value of the upper
parameter, then
* a CORBA::BAD_PARAM exception is raised.
*/
public org.omg.CosTime.TIO new_interval(long lower, long upper)
{
return m_time.new_interval( lower, upper );
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/TimeServer.xinfo
Index: TimeServer.xinfo
===================================================================
<?xml version="1.0"?>
<!--
Copyright (C) The Apache Software Foundation. All rights reserved.
This software is published under the terms of the Apache Software License
version 1.1, a copy of which has been included with this distribution in
the LICENSE.TXT file.
Original contribution by OSM SARL, http://www.osm.net
-->
<blockinfo>
<block>
<version>1.0</version>
</block>
<!--
The TimeServer block provides a single service defined by the
net.osm.time.TimeService interface.
-->
<services>
<service name="org.omg.CosTime.TimeService" version="1.0" />
</services>
<dependencies>
<dependency>
<role>ORB-FACTORY</role>
<service name="org.apache.orb.ORBFactoryService" version="1.0"/>
</dependency>
</dependencies>
</blockinfo>
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/TimeUtils.java
Index: TimeUtils.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.TXT file.
*/
package org.apache.time;
import org.omg.TimeBase.UtcT;
import org.omg.CosTime.TimeUnavailable;
import org.omg.CosTime.TimeService;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Calendar;
/**
* The TimeUtils class contains a set of static utility methods
* supporting maniputlation of UTcT values.
*/
public abstract class TimeUtils {
private static final long STDACCURACCY = 10000;
/**
* Converts a UtcT datastructure to a java.util.Date format.
*/
public static Date convertToDate( UtcT utc ) {
long t = utc.time;
return new Date(t);
}
public static Date convertToDate( long value ) {
long t = convertToUtcT( value ).time;
return new Date(t);
}
public static UtcT convertToUtcT( long value )
{
long tmp = STDACCURACCY >> 32;
return new UtcT
(
value,
(int )( STDACCURACCY & Integer.MAX_VALUE),
(short )(tmp & Short.MAX_VALUE),
(short )0
);
}
/**
* Returns the current time in UtcT format based on the current time
* returned from the local virtual machine. As such, the current time
* returned here may be out of sync with the time returned from a
* TimeService - however, the operation does not involve a server request
* and as such is usefull when setting UtcT default values in local
* valuetype constructors.
*/
public static UtcT dateToUtc( Date date ) {
long tmp = STDACCURACCY >> 32;
return new org.omg.TimeBase.UtcT
(
date.getTime(),
(int )( STDACCURACCY & Integer.MAX_VALUE),
(short )(tmp & Short.MAX_VALUE),
(short )0
);
}
public static UtcT getCurrentTime() {
return dateToUtc( new java.util.Date() );
}
/**
* Returns the current time in the form of a long based on the
* the current time from the supplied time server.
*/
public static long getTime( TimeService time ) throws TimeUnavailable
{
return time.universal_time().time();
}
/**
* Resolves time by attempting to get time from a time server, and if
* unavailable, uses the JVM.
*/
public static long resolveTime( TimeService time )
{
try
{
return getTime( time );
}
catch(Exception e)
{
return getCurrentTime().time;
}
}
}
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/apache/time/package.html
Index: package.html
===================================================================
<body>
<p>
The <code>org.apache.time</code> package contains an implementation of the
<code>org.omg.CosTime.TimeService</code>.
</p>
</body>
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/omg/CosTime/package.html
Index: package.html
===================================================================
<body>
<p>
The <code>org.omg.CosTime</code> package define a TimeService interface
which provides operations for obtaining the current time,
constructing a UTO with specified values for each attribute, and constructing
a TIO with specified upper and lower bounds.</p>
</body>
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/omg/CosTimerEvent/package.html
Index: package.html
===================================================================
<body>
<p>
The <code>org.omg.TimerEvent</code> package defines standard timer event
services.
</p>
</body>
1.1
jakarta-avalon-apps/enterprise/time/src/java/org/omg/TimeBase/package.html
Index: package.html
===================================================================
<body>
<p>
The <code>org.omg.TimeBase</code> package defines standard set of
datastructures dealing with UTC based time and time duration values.
</p>
</body>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>