OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
TypeSupportImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2024 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.type;
22 
23 import java.util.Collection;
24 
26 import org.omg.dds.core.status.Status;
28 import org.omg.dds.pub.DataWriterQos;
30 import org.omg.dds.sub.DataReaderQos;
32 import org.omg.dds.topic.TopicQos;
45 
46 public class TypeSupportImpl<TYPE> extends AbstractTypeSupport<TYPE> {
47  private final OsplServiceEnvironment environment;
48  private final org.opensplice.dds.dcps.TypeSupportImpl oldTypeSupport;
49  private final Class<TYPE> dataType;
50  private final String typeName;
51 
52  @SuppressWarnings("unchecked")
54  Class<TYPE> dataType, String typeName) {
55  super();
56  this.environment = environment;
57  this.dataType = dataType;
58  this.typeName = typeName;
59 
60  String typeSupportName = dataType.getName() + "TypeSupport";
61 
62  try {
63  Class<? extends org.opensplice.dds.dcps.TypeSupportImpl> oldTypeSupportClaz;
64 
65  oldTypeSupportClaz = (Class<? extends org.opensplice.dds.dcps.TypeSupportImpl>) Class
66  .forName(typeSupportName);
67  this.oldTypeSupport = oldTypeSupportClaz.newInstance();
68  } catch (ClassCastException e) {
70  this.environment,
71  "Allocating new TypeSupport failed. "
72  + typeName
73  + "' is not an instance of org.opensplice.dds.dcps.TypeSupportImpl.");
74  } catch (InstantiationException e) {
75  throw new PreconditionNotMetExceptionImpl(this.environment,
76  "Allocating new TypeSupport failed. " + e.getMessage());
77  } catch (IllegalAccessException e) {
78  throw new PreconditionNotMetExceptionImpl(this.environment,
79  "Allocating new TypeSupport failed. " + e.getMessage());
80  } catch (ClassNotFoundException e) {
81  throw new PreconditionNotMetExceptionImpl(this.environment,
82  "Allocating new TypeSupport failed (" + typeSupportName
83  + "); " + e.getMessage());
84  }
85 
86  }
87 
88  @Override
90  return this.environment;
91  }
92 
93  @Override
94  public TYPE newData() {
95  try {
96  return dataType.newInstance();
97  } catch (InstantiationException e) {
98  throw new PreconditionNotMetExceptionImpl(this.environment,
99  "Unable to instantiate data; " + e.getMessage());
100  } catch (IllegalAccessException e) {
101  throw new PreconditionNotMetExceptionImpl(this.environment,
102  "Unable to instantiate data; " + e.getMessage());
103  }
104  }
105 
106  @Override
107  public Class<TYPE> getType() {
108  return this.dataType;
109  }
110 
111  @Override
112  public String getTypeName() {
113  if (this.typeName != null) {
114  return this.typeName;
115  }
116  return oldTypeSupport.get_type_name();
117  }
118 
119  @Override
120  public DDS.TypeSupport getOldTypeSupport() {
121  return this.oldTypeSupport;
122  }
123 
124  @Override
127  DataWriterListener<TYPE> listener,
128  Collection<Class<? extends Status>> statuses) {
129  return new DataWriterImpl<TYPE>(this.environment, publisher,
130  (TopicImpl<TYPE>) topic, qos, listener, statuses);
131  }
132 
133  @Override
135  TopicDescriptionExt<TYPE> topicDescription, DataReaderQos qos,
136  DataReaderListener<TYPE> listener,
137  Collection<Class<? extends Status>> statuses) {
138  return new DataReaderImpl<TYPE>(this.environment, subscriber,
139  topicDescription, qos, listener, statuses);
140  }
141 
142  @Override
144  String topicName, TopicQos qos, TopicListener<TYPE> listener,
145  Collection<Class<? extends Status>> statuses) {
146  return new TopicImpl<TYPE>(this.environment, participant, topicName,
147  this, qos, listener, statuses);
148  }
149 
150 }
Since a org.omg.dds.sub.DataReader is a kind of org.omg.dds.core.Entity, it has the ability to have a...
AbstractDataWriter< TYPE > createDataWriter(PublisherImpl publisher, AbstractTopic< TYPE > topic, DataWriterQos qos, DataWriterListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
AbstractDataReader< TYPE > createDataReader(SubscriberImpl subscriber, TopicDescriptionExt< TYPE > topicDescription, DataReaderQos qos, DataReaderListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
Since org.omg.dds.topic.Topic is a kind of org.omg.dds.core.Entity, it has the ability to have an ass...
Since a org.omg.dds.pub.DataWriter is a kind of org.omg.dds.core.Entity, it has the ability to have a...
AbstractTopic< TYPE > createTopic(DomainParticipantImpl participant, String topicName, TopicQos qos, TopicListener< TYPE > listener, Collection< Class<? extends Status >> statuses)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
Status is the abstract root class for all communication status objects.
Definition: Status.java:41