/*=============================================================================*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*=============================================================================*/
package org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03Wsdl;
import org.apache.ws.resource.lifetime.ResourceTerminationEvent;
import org.apache.ws.resource.lifetime.impl.ResourceTerminationEventImpl;
import org.apache.ws.resource.lifetime.ResourceTerminationListener;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
import org.apache.ws.addressing.EndpointReference;
import org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.JobPropertiesDocument;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
/**
* An abstract JobPort WS-Resource.
* <p/>
* NOTE: This class is generated and is NOT meant to be modified.
*/
public abstract class AbstractJobPortResource
implements org.apache.ws.resource.lifetime.ScheduledResourceTerminationResource,
org.apache.ws.resource.PropertiesResource
{
/**
* The resource ID of the instance.
*/
protected String m_id;
/**
* The set of properties associated with this resource.
*/
protected org.apache.ws.resource.properties.ResourcePropertySet m_propSet;
/**
* A list of termination listeners to be notified when the resource is terminated.
*/
private List m_terminationListeners = new ArrayList();
private EndpointReference m_endpointReference;
/**
* Returns the current time from the prop set.
*
* @return java.util.Calendar
*/
public java.util.Calendar getCurrentTime( )
{
return org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.getDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) m_propSet
.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME ) );
}
/**
* DOCUMENT_ME
*
* @param id DOCUMENT_ME
*/
public void setID( Object id )
{
if ( m_id != null )
{
throw new IllegalStateException( "This resource's ID has already been set." );
}
try
{
m_id = (String) id;
}
catch ( ClassCastException cce )
{
throw new IllegalArgumentException( "Specified ID is not a String." );
}
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public Object getID( )
{
return m_id;
}
/**
* @see org.apache.ws.resource.PropertiesResource#setResourcePropertySet(org.apache.ws.resource.properties.ResourcePropertySet)
*/
public void setResourcePropertySet( org.apache.ws.resource.properties.ResourcePropertySet propSet )
{
m_propSet = propSet;
}
/**
* @see org.apache.ws.resource.PropertiesResource#getResourcePropertySet()
*/
public org.apache.ws.resource.properties.ResourcePropertySet getResourcePropertySet( )
{
return m_propSet;
}
/**
* DOCUMENT_ME
*
* @param time DOCUMENT_ME
*/
public void setTerminationTime( java.util.Calendar time )
{
org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.setDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) getResourcePropertySet( )
.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME ),
time );
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public java.util.Calendar getTerminationTime( )
{
return org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.getDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) m_propSet
.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME ) );
}
/**
* Adds a listener to be invoked when the resource has been terminated.
*
* @param listener
*/
public void addTerminationListener(ResourceTerminationListener listener)
{
m_terminationListeners.add(listener);
}
public abstract PrinterPortResource getPrinterResource();
/**
* DOCUMENT_ME
*/
public void destroy( )
{
JobPropertiesDocument jobPropDoc = (JobPropertiesDocument) ((XmlBeansResourcePropertySet)getResourcePropertySet()).toXmlObject();
org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.JobPropertiesDocument.JobProperties jobProperties = jobPropDoc.getJobProperties();
java.math.BigInteger jobId = jobProperties.getJobId();
PrinterPortResource printerResource = getPrinterResource();
ResourceProperty printerJobProperties =
printerResource.getResourcePropertySet( ).get( PrinterPortPropertyQNames.JOB_PROPERTIES );
Iterator iterator = printerJobProperties.iterator();
JobPropertiesDocument.JobProperties properties = null;
while (iterator.hasNext())
{
properties = (JobPropertiesDocument.JobProperties) iterator.next();
if(properties.getJobId().equals(jobId))
{
break;
}
}
if(properties != null)
{
printerJobProperties.remove(properties);
}
ResourceTerminationEvent rte = new ResourceTerminationEventImpl(getID(),"Job Destroyed");
for (int i = 0; i < m_terminationListeners.size(); i++)
{
ResourceTerminationListener resourceTerminationListener = (ResourceTerminationListener) m_terminationListeners.get(i);
resourceTerminationListener.terminationOccurred(rte);
}
return;
}
/**
* DOCUMENT_ME
*/
public void init( )
{
org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.JobPropertiesDocument propsDoc =
org.oasisOpen.docs.wsrf.x2005.x01.wsrfInterop20Draft03.JobPropertiesDocument.Factory.newInstance( );
m_propSet = new org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet( propsDoc );
// initialize wsrl:CurrentTime property
org.apache.ws.resource.properties.ResourceProperty prop =
m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME );
org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.CurrentTimeDocument currTime =
org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.CurrentTimeDocument.Factory.newInstance( );
currTime.setCurrentTime( java.util.Calendar.getInstance( ) );
prop.add( currTime );
prop.setCallback( new org.apache.ws.resource.lifetime.callback.CurrentTimeCallback( ) );
// initialize wsrl:TerminationTime property
prop =
m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME );
org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.TerminationTimeDocument termTime =
org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.TerminationTimeDocument.Factory
.newInstance( );
Calendar instance = Calendar.getInstance();
instance.set(Calendar.YEAR, instance.get(Calendar.YEAR) + 1);
termTime.setTerminationTime(instance);
//termTime.setNilTerminationTime( );
prop.add(termTime);
}
/**
* Returns the EndpointReference associated with this Resource.
*
* @return The Resource's EndpointReference or null if the EndpointReference has not been set.
*
* Note: It is the responsibility of the Resource creator to set the EndpointReference (i.e. ResourceHome impl)
*/
public EndpointReference getEndpointReference()
{
return m_endpointReference;
}
/**
* Sets the EndpointReference associated with this Resource.
*
* @param epr The Resource's EndpointReference.
*
* Note: It is the responsibility of the Resource creator to set the EndpointReference (i.e. ResourceHome impl)
*/
public void setEndpointReference(EndpointReference epr)
{
m_endpointReference = epr;
}
}